mirror of
https://github.com/fafhrd91/actix-web
synced 2025-01-31 02:52:53 +01:00
add test server data test
This commit is contained in:
parent
48476362a3
commit
0cb1b0642f
21
src/test.rs
21
src/test.rs
@ -962,7 +962,7 @@ mod tests {
|
|||||||
use std::time::SystemTime;
|
use std::time::SystemTime;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::{http::header, web, App, HttpResponse};
|
use crate::{http::header, web, App, HttpResponse, Responder};
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn test_basics() {
|
async fn test_basics() {
|
||||||
@ -1148,6 +1148,25 @@ mod tests {
|
|||||||
assert!(res.status().is_success());
|
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]
|
#[actix_rt::test]
|
||||||
async fn test_actor() {
|
async fn test_actor() {
|
||||||
use actix::Actor;
|
use actix::Actor;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user