1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-06-25 06:39:22 +02:00

Update tests

This commit is contained in:
Yuki Okushi
2020-03-08 16:42:45 +09:00
parent a9a475d555
commit e718f65121
12 changed files with 151 additions and 87 deletions

View File

@ -107,17 +107,15 @@ async fn test_form() {
#[actix_rt::test]
async fn test_timeout() {
let srv = test::start(|| {
App::new().service(web::resource("/").route(web::to(|| {
async {
actix_rt::time::delay_for(Duration::from_millis(200)).await;
Ok::<_, Error>(HttpResponse::Ok().body(STR))
}
App::new().service(web::resource("/").route(web::to(|| async {
actix_rt::time::delay_for(Duration::from_millis(200)).await;
Ok::<_, Error>(HttpResponse::Ok().body(STR))
})))
});
let connector = awc::Connector::new()
.connector(actix_connect::new_connector(
actix_connect::start_default_resolver(),
actix_connect::start_default_resolver().await.unwrap(),
))
.timeout(Duration::from_secs(15))
.finish();
@ -137,11 +135,9 @@ async fn test_timeout() {
#[actix_rt::test]
async fn test_timeout_override() {
let srv = test::start(|| {
App::new().service(web::resource("/").route(web::to(|| {
async {
actix_rt::time::delay_for(Duration::from_millis(200)).await;
Ok::<_, Error>(HttpResponse::Ok().body(STR))
}
App::new().service(web::resource("/").route(web::to(|| async {
actix_rt::time::delay_for(Duration::from_millis(200)).await;
Ok::<_, Error>(HttpResponse::Ok().body(STR))
})))
});
@ -177,7 +173,8 @@ async fn test_connection_reuse() {
))
.tcp(),
)
});
})
.await;
let client = awc::Client::default();
@ -214,7 +211,8 @@ async fn test_connection_force_close() {
))
.tcp(),
)
});
})
.await;
let client = awc::Client::default();
@ -253,7 +251,8 @@ async fn test_connection_server_close() {
))
.tcp(),
)
});
})
.await;
let client = awc::Client::default();
@ -291,7 +290,8 @@ async fn test_connection_wait_queue() {
))
.tcp(),
)
});
})
.await;
let client = awc::Client::build()
.connector(awc::Connector::new().limit(1).finish())
@ -339,7 +339,8 @@ async fn test_connection_wait_queue_force_close() {
))
.tcp(),
)
});
})
.await;
let client = awc::Client::build()
.connector(awc::Connector::new().limit(1).finish())

View File

@ -32,14 +32,14 @@ async fn test_connection_window_size() {
let srv = test_server(move || {
HttpService::build()
.h2(map_config(
App::new().service(
web::resource("/").route(web::to(|| HttpResponse::Ok())),
),
App::new()
.service(web::resource("/").route(web::to(|| HttpResponse::Ok()))),
|_| AppConfig::default(),
))
.openssl(ssl_acceptor())
.map_err(|_| ())
});
})
.await;
// disable ssl verification
let mut builder = SslConnector::builder(SslMethod::tls()).unwrap();

View File

@ -72,7 +72,8 @@ async fn _test_connection_reuse_h2() {
.openssl(ssl_acceptor())
.map_err(|_| ()),
)
});
})
.await;
// disable ssl verification
let mut config = ClientConfig::new();

View File

@ -53,7 +53,8 @@ async fn test_connection_reuse_h2() {
.openssl(ssl_acceptor())
.map_err(|_| ()),
)
});
})
.await;
// disable ssl verification
let mut builder = SslConnector::builder(SslMethod::tls()).unwrap();

View File

@ -38,7 +38,8 @@ async fn test_simple() {
})
.finish(|_| ok::<_, Error>(Response::NotFound()))
.tcp()
});
})
.await;
// client service
let mut framed = srv.ws().await.unwrap();