Function ajars_actix_web::actix_web::test::call_service [−][src]
pub async fn call_service<S, R, B, E>(
app: &'_ S,
req: R
) -> <S as Service<R>>::Response where
E: Debug,
S: Service<R, Response = ServiceResponse<B>, Error = E>,
Expand description
Calls service and waits for response future completion.
use actix_web::{test, web, App, HttpResponse, http::StatusCode}; #[actix_rt::test] async fn test_response() { let app = test::init_service( App::new() .service(web::resource("/test").to(|| async { HttpResponse::Ok() })) ).await; // Create request object let req = test::TestRequest::with_uri("/test").to_request(); // Call application let resp = test::call_service(&app, req).await; assert_eq!(resp.status(), StatusCode::OK); }