mirror of https://github.com/fafhrd91/actix-web
add test
This commit is contained in:
parent
e48847efac
commit
3f6d853d2f
|
@ -82,7 +82,7 @@ where
|
|||
T: ServiceFactory<
|
||||
ServiceRequest,
|
||||
Config = (),
|
||||
Response = ServiceResponse,
|
||||
Response = ServiceResponse<B>,
|
||||
Error = Error,
|
||||
InitError = (),
|
||||
>,
|
||||
|
@ -813,4 +813,26 @@ mod tests {
|
|||
let resp = call_service(&srv, req).await;
|
||||
assert_eq!(resp.status(), StatusCode::BAD_REQUEST);
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn test_middleware_body_type() {
|
||||
let srv = init_service(
|
||||
App::new().service(
|
||||
web::resource("/test")
|
||||
.wrap_fn(|req, srv| {
|
||||
let fut = srv.call(req);
|
||||
async { Ok(fut.await?.map_into_right_body::<()>()) }
|
||||
})
|
||||
.route(web::get().to(|| async { "hello" })),
|
||||
),
|
||||
)
|
||||
.await;
|
||||
|
||||
// test if `try_into_bytes()` is preserved across scope layer
|
||||
use actix_http::body::MessageBody as _;
|
||||
let req = TestRequest::with_uri("/test").to_request();
|
||||
let resp = call_service(&srv, req).await;
|
||||
let body = resp.into_body();
|
||||
assert_eq!(body.try_into_bytes().unwrap(), b"hello".as_ref());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue