mirror of
https://github.com/actix/actix-web.git
synced 2024-12-30 03:50:42 +00:00
add test server data test
This commit is contained in:
parent
48476362a3
commit
0cb1b0642f
1 changed files with 20 additions and 1 deletions
21
src/test.rs
21
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<usize>) -> 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;
|
||||
|
|
Loading…
Reference in a new issue