From bc58dbb2f5fa8cae488cf3ac632732f99a8f0827 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Mon, 8 Apr 2019 11:19:56 -0700 Subject: [PATCH] add async expect service test --- actix-http/tests/test_server.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/actix-http/tests/test_server.rs b/actix-http/tests/test_server.rs index e7b539372..e53ff0212 100644 --- a/actix-http/tests/test_server.rs +++ b/actix-http/tests/test_server.rs @@ -9,6 +9,7 @@ use actix_service::{fn_cfg_factory, fn_service, NewService}; use bytes::{Bytes, BytesMut}; use futures::future::{self, ok, Future}; use futures::stream::{once, Stream}; +use tokio_timer::sleep; use actix_http::body::Body; use actix_http::error::PayloadError; @@ -185,11 +186,13 @@ fn test_expect_continue_h1() { let srv = TestServer::new(|| { HttpService::build() .expect(fn_service(|req: Request| { - if req.head().uri.query() == Some("yes=") { - Ok(req) - } else { - Err(error::ErrorPreconditionFailed("error")) - } + sleep(Duration::from_millis(20)).then(move |_| { + if req.head().uri.query() == Some("yes=") { + Ok(req) + } else { + Err(error::ErrorPreconditionFailed("error")) + } + }) })) .h1(|_| future::ok::<_, ()>(Response::Ok().finish())) });