mirror of https://github.com/fafhrd91/actix-web
duplicate one test for io-uring feature
This commit is contained in:
parent
09328847b3
commit
3f72074270
|
@ -214,7 +214,7 @@ mod tests {
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn test_named_file_non_ascii_file_name() {
|
async fn test_named_file_non_ascii_file_name() {
|
||||||
let file = crate::named::File::open("Cargo.toml").unwrap();
|
let file = crate::named::File::open("Cargo.toml").await.unwrap();
|
||||||
|
|
||||||
let mut file = NamedFile::from_file(file, "貨物.toml").unwrap();
|
let mut file = NamedFile::from_file(file, "貨物.toml").unwrap();
|
||||||
{
|
{
|
||||||
|
@ -652,6 +652,42 @@ mod tests {
|
||||||
assert!(format!("{:?}", bytes).contains("/tests/test.png"));
|
assert!(format!("{:?}", bytes).contains("/tests/test.png"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: reduce duplicate test between features.
|
||||||
|
#[cfg(feature = "io-uring")]
|
||||||
|
#[test]
|
||||||
|
fn test_static_files_io_uring() {
|
||||||
|
tokio_uring::start(async {
|
||||||
|
let srv = test::init_service(
|
||||||
|
App::new().service(Files::new("/", ".").show_files_listing()),
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
let req = TestRequest::with_uri("/missing").to_request();
|
||||||
|
|
||||||
|
let resp = test::call_service(&srv, req).await;
|
||||||
|
assert_eq!(resp.status(), StatusCode::NOT_FOUND);
|
||||||
|
|
||||||
|
let srv = test::init_service(App::new().service(Files::new("/", "."))).await;
|
||||||
|
|
||||||
|
let req = TestRequest::default().to_request();
|
||||||
|
let resp = test::call_service(&srv, req).await;
|
||||||
|
assert_eq!(resp.status(), StatusCode::NOT_FOUND);
|
||||||
|
|
||||||
|
let srv = test::init_service(
|
||||||
|
App::new().service(Files::new("/", ".").show_files_listing()),
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
let req = TestRequest::with_uri("/tests").to_request();
|
||||||
|
let resp = test::call_service(&srv, req).await;
|
||||||
|
assert_eq!(
|
||||||
|
resp.headers().get(header::CONTENT_TYPE).unwrap(),
|
||||||
|
"text/html; charset=utf-8"
|
||||||
|
);
|
||||||
|
|
||||||
|
let bytes = test::read_body(resp).await;
|
||||||
|
assert!(format!("{:?}", bytes).contains("/tests/test.png"));
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn test_redirect_to_slash_directory() {
|
async fn test_redirect_to_slash_directory() {
|
||||||
// should not redirect if no index and files listing is disabled
|
// should not redirect if no index and files listing is disabled
|
||||||
|
|
Loading…
Reference in New Issue