diff --git a/src/test.rs b/src/test.rs index a10490fd5..5f5fdc487 100644 --- a/src/test.rs +++ b/src/test.rs @@ -962,7 +962,7 @@ mod tests { use std::time::SystemTime; use super::*; - use crate::{http::header, web, App, HttpResponse}; + use crate::{http::header, web, App, HttpResponse, Responder}; #[actix_rt::test] async fn test_basics() { @@ -1148,6 +1148,25 @@ mod tests { assert!(res.status().is_success()); } + #[actix_rt::test] + async fn test_server_data() { + async fn handler(data: web::Data) -> impl Responder { + assert_eq!(**data, 10); + HttpResponse::Ok() + } + + let mut app = init_service( + App::new() + .data(10usize) + .service(web::resource("/index.html").to(handler)), + ) + .await; + + let req = TestRequest::post().uri("/index.html").to_request(); + let res = app.call(req).await.unwrap(); + assert!(res.status().is_success()); + } + #[actix_rt::test] async fn test_actor() { use actix::Actor;