mirror of
https://github.com/actix/actix-web.git
synced 2025-04-06 10:09:44 +00:00
[actix-files] modify method check tests (NamedFile -> Files)
This commit is contained in:
parent
da3d33f81d
commit
86436bb4fe
1 changed files with 14 additions and 7 deletions
|
@ -1045,17 +1045,24 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_named_file_not_allowed() {
|
||||
let file = NamedFile::open("Cargo.toml").unwrap();
|
||||
fn test_files_not_allowed() {
|
||||
let mut srv = test::init_service(
|
||||
App::new().service(Files::new("/", ".")),
|
||||
);
|
||||
|
||||
let req = TestRequest::default()
|
||||
.uri("/Cargo.toml")
|
||||
.method(Method::POST)
|
||||
.to_http_request();
|
||||
let resp = file.respond_to(&req).unwrap();
|
||||
.to_request();
|
||||
|
||||
let resp = test::call_service(&mut srv, req);
|
||||
assert_eq!(resp.status(), StatusCode::METHOD_NOT_ALLOWED);
|
||||
|
||||
let file = NamedFile::open("Cargo.toml").unwrap();
|
||||
let req = TestRequest::default().method(Method::PUT).to_http_request();
|
||||
let resp = file.respond_to(&req).unwrap();
|
||||
let mut srv = test::init_service(
|
||||
App::new().service(Files::new("/", ".")),
|
||||
);
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue