mirror of
https://github.com/fafhrd91/actix-web
synced 2025-06-26 15:07:42 +02:00
Update tests
This commit is contained in:
@ -45,7 +45,8 @@ async fn test_h1() -> io::Result<()> {
|
||||
HttpService::build()
|
||||
.h1(|_| future::ok::<_, Error>(Response::Ok().finish()))
|
||||
.rustls(ssl_acceptor())
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let response = srv.sget("/").send().await.unwrap();
|
||||
assert!(response.status().is_success());
|
||||
@ -58,7 +59,8 @@ async fn test_h2() -> io::Result<()> {
|
||||
HttpService::build()
|
||||
.h2(|_| future::ok::<_, Error>(Response::Ok().finish()))
|
||||
.rustls(ssl_acceptor())
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let response = srv.sget("/").send().await.unwrap();
|
||||
assert!(response.status().is_success());
|
||||
@ -75,7 +77,8 @@ async fn test_h1_1() -> io::Result<()> {
|
||||
future::ok::<_, Error>(Response::Ok().finish())
|
||||
})
|
||||
.rustls(ssl_acceptor())
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let response = srv.sget("/").send().await.unwrap();
|
||||
assert!(response.status().is_success());
|
||||
@ -92,7 +95,8 @@ async fn test_h2_1() -> io::Result<()> {
|
||||
future::ok::<_, Error>(Response::Ok().finish())
|
||||
})
|
||||
.rustls(ssl_acceptor())
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let response = srv.sget("/").send().await.unwrap();
|
||||
assert!(response.status().is_success());
|
||||
@ -109,7 +113,8 @@ async fn test_h2_body1() -> io::Result<()> {
|
||||
Ok::<_, Error>(Response::Ok().body(body))
|
||||
})
|
||||
.rustls(ssl_acceptor())
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let response = srv.sget("/").send_body(data.clone()).await.unwrap();
|
||||
assert!(response.status().is_success());
|
||||
@ -136,7 +141,8 @@ async fn test_h2_content_length() {
|
||||
future::ok::<_, ()>(Response::new(statuses[indx]))
|
||||
})
|
||||
.rustls(ssl_acceptor())
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let header = HeaderName::from_static("content-length");
|
||||
let value = HeaderValue::from_static("0");
|
||||
@ -195,7 +201,7 @@ async fn test_h2_headers() {
|
||||
future::ok::<_, ()>(config.body(data.clone()))
|
||||
})
|
||||
.rustls(ssl_acceptor())
|
||||
});
|
||||
}).await;
|
||||
|
||||
let response = srv.sget("/").send().await.unwrap();
|
||||
assert!(response.status().is_success());
|
||||
@ -233,7 +239,8 @@ async fn test_h2_body2() {
|
||||
HttpService::build()
|
||||
.h2(|_| future::ok::<_, ()>(Response::Ok().body(STR)))
|
||||
.rustls(ssl_acceptor())
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let response = srv.sget("/").send().await.unwrap();
|
||||
assert!(response.status().is_success());
|
||||
@ -249,7 +256,8 @@ async fn test_h2_head_empty() {
|
||||
HttpService::build()
|
||||
.finish(|_| ok::<_, ()>(Response::Ok().body(STR)))
|
||||
.rustls(ssl_acceptor())
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let response = srv.shead("/").send().await.unwrap();
|
||||
assert!(response.status().is_success());
|
||||
@ -276,7 +284,8 @@ async fn test_h2_head_binary() {
|
||||
ok::<_, ()>(Response::Ok().content_length(STR.len() as u64).body(STR))
|
||||
})
|
||||
.rustls(ssl_acceptor())
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let response = srv.shead("/").send().await.unwrap();
|
||||
assert!(response.status().is_success());
|
||||
@ -300,7 +309,8 @@ async fn test_h2_head_binary2() {
|
||||
HttpService::build()
|
||||
.h2(|_| ok::<_, ()>(Response::Ok().body(STR)))
|
||||
.rustls(ssl_acceptor())
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let response = srv.shead("/").send().await.unwrap();
|
||||
assert!(response.status().is_success());
|
||||
@ -325,7 +335,8 @@ async fn test_h2_body_length() {
|
||||
)
|
||||
})
|
||||
.rustls(ssl_acceptor())
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let response = srv.sget("/").send().await.unwrap();
|
||||
assert!(response.status().is_success());
|
||||
@ -348,7 +359,8 @@ async fn test_h2_body_chunked_explicit() {
|
||||
)
|
||||
})
|
||||
.rustls(ssl_acceptor())
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let response = srv.sget("/").send().await.unwrap();
|
||||
assert!(response.status().is_success());
|
||||
@ -376,7 +388,8 @@ async fn test_h2_response_http_error_handling() {
|
||||
}))
|
||||
}))
|
||||
.rustls(ssl_acceptor())
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let response = srv.sget("/").send().await.unwrap();
|
||||
assert_eq!(response.status(), http::StatusCode::INTERNAL_SERVER_ERROR);
|
||||
@ -392,7 +405,8 @@ async fn test_h2_service_error() {
|
||||
HttpService::build()
|
||||
.h2(|_| err::<Response, Error>(error::ErrorBadRequest("error")))
|
||||
.rustls(ssl_acceptor())
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let response = srv.sget("/").send().await.unwrap();
|
||||
assert_eq!(response.status(), http::StatusCode::BAD_REQUEST);
|
||||
@ -408,7 +422,8 @@ async fn test_h1_service_error() {
|
||||
HttpService::build()
|
||||
.h1(|_| err::<Response, Error>(error::ErrorBadRequest("error")))
|
||||
.rustls(ssl_acceptor())
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let response = srv.sget("/").send().await.unwrap();
|
||||
assert_eq!(response.status(), http::StatusCode::BAD_REQUEST);
|
||||
|
Reference in New Issue
Block a user