1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-05-19 16:58:14 +00:00

sync to master branch by adding test_wrap

This commit is contained in:
Jon Lim 2024-04-16 22:55:37 -07:00
parent 6d3fff281b
commit 89f78190bd

View file

@ -6,6 +6,7 @@ use actix_web::{
http::{
self,
header::{HeaderName, HeaderValue},
StatusCode,
},
web, App, Error, HttpRequest, HttpResponse, Responder,
};
@ -371,6 +372,20 @@ async fn test_auto_async() {
assert!(response.status().is_success());
}
#[actix_web::test]
async fn test_wrap() {
let srv = actix_test::start(|| App::new().service(get_wrap));
let request = srv.request(http::Method::GET, srv.url("/test/wrap"));
let mut response = request.send().await.unwrap();
assert_eq!(response.status(), StatusCode::NOT_FOUND);
assert!(response.headers().contains_key("custom-header"));
let body = response.body().await.unwrap();
let body = String::from_utf8(body.to_vec()).unwrap();
assert!(body.contains("wrong number of parameters"));
}
#[scope("/test")]
mod scope_module {
use actix_web::{delete, get, post, route, routes, web, HttpResponse, Responder};