mirror of https://github.com/fafhrd91/actix-web
test util body errors only require Debug
This commit is contained in:
parent
84d7320f42
commit
b168fcd606
12
src/test.rs
12
src/test.rs
|
@ -1,6 +1,6 @@
|
||||||
//! Various helpers for Actix applications to use during testing.
|
//! Various helpers for Actix applications to use during testing.
|
||||||
|
|
||||||
use std::{borrow::Cow, net::SocketAddr, rc::Rc};
|
use std::{borrow::Cow, fmt, net::SocketAddr, rc::Rc};
|
||||||
|
|
||||||
pub use actix_http::test::TestBuffer;
|
pub use actix_http::test::TestBuffer;
|
||||||
use actix_http::{
|
use actix_http::{
|
||||||
|
@ -157,12 +157,12 @@ pub async fn read_response<S, B>(app: &S, req: Request) -> Bytes
|
||||||
where
|
where
|
||||||
S: Service<Request, Response = ServiceResponse<B>, Error = Error>,
|
S: Service<Request, Response = ServiceResponse<B>, Error = Error>,
|
||||||
B: MessageBody + Unpin,
|
B: MessageBody + Unpin,
|
||||||
B::Error: Into<Error>,
|
B::Error: fmt::Debug,
|
||||||
{
|
{
|
||||||
let resp = app
|
let resp = app
|
||||||
.call(req)
|
.call(req)
|
||||||
.await
|
.await
|
||||||
.unwrap_or_else(|e| panic!("read_response failed at application call: {}", e));
|
.unwrap_or_else(|e| panic!("read_response failed at application call: {:?}", e));
|
||||||
|
|
||||||
let body = resp.into_body();
|
let body = resp.into_body();
|
||||||
let mut bytes = BytesMut::new();
|
let mut bytes = BytesMut::new();
|
||||||
|
@ -204,7 +204,7 @@ where
|
||||||
pub async fn read_body<B>(res: ServiceResponse<B>) -> Bytes
|
pub async fn read_body<B>(res: ServiceResponse<B>) -> Bytes
|
||||||
where
|
where
|
||||||
B: MessageBody + Unpin,
|
B: MessageBody + Unpin,
|
||||||
B::Error: Into<Error>,
|
B::Error: fmt::Debug,
|
||||||
{
|
{
|
||||||
let body = res.into_body();
|
let body = res.into_body();
|
||||||
let mut bytes = BytesMut::new();
|
let mut bytes = BytesMut::new();
|
||||||
|
@ -257,7 +257,7 @@ where
|
||||||
pub async fn read_body_json<T, B>(res: ServiceResponse<B>) -> T
|
pub async fn read_body_json<T, B>(res: ServiceResponse<B>) -> T
|
||||||
where
|
where
|
||||||
B: MessageBody + Unpin,
|
B: MessageBody + Unpin,
|
||||||
B::Error: Into<Error>,
|
B::Error: fmt::Debug,
|
||||||
T: DeserializeOwned,
|
T: DeserializeOwned,
|
||||||
{
|
{
|
||||||
let body = read_body(res).await;
|
let body = read_body(res).await;
|
||||||
|
@ -308,7 +308,7 @@ pub async fn read_response_json<S, B, T>(app: &S, req: Request) -> T
|
||||||
where
|
where
|
||||||
S: Service<Request, Response = ServiceResponse<B>, Error = Error>,
|
S: Service<Request, Response = ServiceResponse<B>, Error = Error>,
|
||||||
B: MessageBody + Unpin,
|
B: MessageBody + Unpin,
|
||||||
B::Error: Into<Error>,
|
B::Error: fmt::Debug,
|
||||||
T: DeserializeOwned,
|
T: DeserializeOwned,
|
||||||
{
|
{
|
||||||
let body = read_response(app, req).await;
|
let body = read_response(app, req).await;
|
||||||
|
|
Loading…
Reference in New Issue