mirror of https://github.com/fafhrd91/actix-web
[actix-files] modify method check tests (NamedFile -> Files)
This commit is contained in:
parent
da3d33f81d
commit
86436bb4fe
|
@ -1045,17 +1045,24 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_named_file_not_allowed() {
|
fn test_files_not_allowed() {
|
||||||
let file = NamedFile::open("Cargo.toml").unwrap();
|
let mut srv = test::init_service(
|
||||||
|
App::new().service(Files::new("/", ".")),
|
||||||
|
);
|
||||||
|
|
||||||
let req = TestRequest::default()
|
let req = TestRequest::default()
|
||||||
|
.uri("/Cargo.toml")
|
||||||
.method(Method::POST)
|
.method(Method::POST)
|
||||||
.to_http_request();
|
.to_request();
|
||||||
let resp = file.respond_to(&req).unwrap();
|
|
||||||
|
let resp = test::call_service(&mut srv, req);
|
||||||
assert_eq!(resp.status(), StatusCode::METHOD_NOT_ALLOWED);
|
assert_eq!(resp.status(), StatusCode::METHOD_NOT_ALLOWED);
|
||||||
|
|
||||||
let file = NamedFile::open("Cargo.toml").unwrap();
|
let mut srv = test::init_service(
|
||||||
let req = TestRequest::default().method(Method::PUT).to_http_request();
|
App::new().service(Files::new("/", ".")),
|
||||||
let resp = file.respond_to(&req).unwrap();
|
);
|
||||||
|
let req = TestRequest::default().method(Method::PUT).uri("/Cargo.toml").to_request();
|
||||||
|
let resp = test::call_service(&mut srv, req);
|
||||||
assert_eq!(resp.status(), StatusCode::METHOD_NOT_ALLOWED);
|
assert_eq!(resp.status(), StatusCode::METHOD_NOT_ALLOWED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue