1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-07-03 20:45:46 +00:00

add test server data test

This commit is contained in:
Nikolay Kim 2019-12-20 23:18:59 +06:00
parent 48476362a3
commit 0cb1b0642f

View file

@ -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;