From 8cdbab3416ecc562a6ca5aad6b7bba5b3dce1dfd Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sat, 22 Jul 2023 01:57:44 +0100 Subject: [PATCH] refactor: remove web dev dep from http-test --- actix-http-test/Cargo.toml | 1 - actix-http-test/src/lib.rs | 25 +++++++++++-------------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/actix-http-test/Cargo.toml b/actix-http-test/Cargo.toml index 87422551d..7f00ba30a 100644 --- a/actix-http-test/Cargo.toml +++ b/actix-http-test/Cargo.toml @@ -50,5 +50,4 @@ tls-openssl = { version = "0.10.55", package = "openssl", optional = true } tokio = { version = "1.24.2", features = ["sync"] } [dev-dependencies] -actix-web = { version = "4", default-features = false, features = ["cookies"] } actix-http = "3" diff --git a/actix-http-test/src/lib.rs b/actix-http-test/src/lib.rs index 8dcbe759d..2f1725d1c 100644 --- a/actix-http-test/src/lib.rs +++ b/actix-http-test/src/lib.rs @@ -31,24 +31,20 @@ use tokio::sync::mpsc; /// for HTTP applications. /// /// # Examples -/// ```no_run -/// use actix_http::HttpService; +/// +/// ``` +/// use actix_http::{HttpService, Response, Error, StatusCode}; /// use actix_http_test::test_server; -/// use actix_service::map_config; -/// use actix_service::ServiceFactoryExt; -/// use actix_web::{dev::AppConfig, web, App, Error, HttpResponse}; +/// use actix_service::{fn_service, map_config, ServiceFactoryExt as _}; /// -/// async fn my_handler() -> Result { -/// Ok(HttpResponse::Ok().into()) -/// } -/// -/// #[actix_web::test] +/// #[actix_rt::test] +/// # async fn hidden_test() {} /// async fn test_example() { /// let srv = test_server(|| { -/// let app = App::new().service(web::resource("/").to(my_handler)); -/// /// HttpService::build() -/// .h1(map_config(app, |_| AppConfig::default())) +/// .h1(fn_service(|req| async move { +/// Ok::<_, Error>(Response::ok()) +/// })) /// .tcp() /// .map_err(|_| ()) /// }) @@ -57,8 +53,9 @@ use tokio::sync::mpsc; /// let req = srv.get("/"); /// let response = req.send().await.unwrap(); /// -/// assert!(response.status().is_success()); +/// assert_eq!(response.status(), StatusCode::OK); /// } +/// # actix_rt::System::new().block_on(test_example()); /// ``` pub async fn test_server>(factory: F) -> TestServer { let tcp = net::TcpListener::bind("127.0.0.1:0").unwrap();