mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-30 18:44:35 +01:00
update tests
This commit is contained in:
parent
f37880d89c
commit
03d6b04eef
24
src/fs.rs
24
src/fs.rs
@ -650,7 +650,7 @@ mod tests {
|
|||||||
let _f: &mut File = &mut file;
|
let _f: &mut File = &mut file;
|
||||||
}
|
}
|
||||||
|
|
||||||
let resp = file.respond_to(HttpRequest::default()).unwrap();
|
let resp = file.respond_to(&HttpRequest::default()).unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resp.headers().get(header::CONTENT_TYPE).unwrap(),
|
resp.headers().get(header::CONTENT_TYPE).unwrap(),
|
||||||
"text/x-toml"
|
"text/x-toml"
|
||||||
@ -676,7 +676,7 @@ mod tests {
|
|||||||
let _f: &mut File = &mut file;
|
let _f: &mut File = &mut file;
|
||||||
}
|
}
|
||||||
|
|
||||||
let resp = file.respond_to(HttpRequest::default()).unwrap();
|
let resp = file.respond_to(&HttpRequest::default()).unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resp.headers().get(header::CONTENT_TYPE).unwrap(),
|
resp.headers().get(header::CONTENT_TYPE).unwrap(),
|
||||||
"image/png"
|
"image/png"
|
||||||
@ -702,7 +702,7 @@ mod tests {
|
|||||||
let _f: &mut File = &mut file;
|
let _f: &mut File = &mut file;
|
||||||
}
|
}
|
||||||
|
|
||||||
let resp = file.respond_to(HttpRequest::default()).unwrap();
|
let resp = file.respond_to(&HttpRequest::default()).unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resp.headers().get(header::CONTENT_TYPE).unwrap(),
|
resp.headers().get(header::CONTENT_TYPE).unwrap(),
|
||||||
"application/octet-stream"
|
"application/octet-stream"
|
||||||
@ -729,7 +729,7 @@ mod tests {
|
|||||||
let _f: &mut File = &mut file;
|
let _f: &mut File = &mut file;
|
||||||
}
|
}
|
||||||
|
|
||||||
let resp = file.respond_to(HttpRequest::default()).unwrap();
|
let resp = file.respond_to(&HttpRequest::default()).unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resp.headers().get(header::CONTENT_TYPE).unwrap(),
|
resp.headers().get(header::CONTENT_TYPE).unwrap(),
|
||||||
"text/x-toml"
|
"text/x-toml"
|
||||||
@ -748,7 +748,7 @@ mod tests {
|
|||||||
let req = TestRequest::default().method(Method::POST).finish();
|
let req = TestRequest::default().method(Method::POST).finish();
|
||||||
let file = NamedFile::open("Cargo.toml").unwrap();
|
let file = NamedFile::open("Cargo.toml").unwrap();
|
||||||
|
|
||||||
let resp = file.only_get().respond_to(req).unwrap();
|
let resp = file.only_get().respond_to(&req).unwrap();
|
||||||
assert_eq!(resp.status(), StatusCode::METHOD_NOT_ALLOWED);
|
assert_eq!(resp.status(), StatusCode::METHOD_NOT_ALLOWED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -756,7 +756,7 @@ mod tests {
|
|||||||
fn test_named_file_any_method() {
|
fn test_named_file_any_method() {
|
||||||
let req = TestRequest::default().method(Method::POST).finish();
|
let req = TestRequest::default().method(Method::POST).finish();
|
||||||
let file = NamedFile::open("Cargo.toml").unwrap();
|
let file = NamedFile::open("Cargo.toml").unwrap();
|
||||||
let resp = file.respond_to(req).unwrap();
|
let resp = file.respond_to(&req).unwrap();
|
||||||
assert_eq!(resp.status(), StatusCode::OK);
|
assert_eq!(resp.status(), StatusCode::OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -765,7 +765,7 @@ mod tests {
|
|||||||
let mut st = StaticFiles::new(".").show_files_listing();
|
let mut st = StaticFiles::new(".").show_files_listing();
|
||||||
st.accessible = false;
|
st.accessible = false;
|
||||||
let resp = st.handle(HttpRequest::default())
|
let resp = st.handle(HttpRequest::default())
|
||||||
.respond_to(HttpRequest::default())
|
.respond_to(&HttpRequest::default())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let resp = resp.as_msg();
|
let resp = resp.as_msg();
|
||||||
assert_eq!(resp.status(), StatusCode::NOT_FOUND);
|
assert_eq!(resp.status(), StatusCode::NOT_FOUND);
|
||||||
@ -773,7 +773,7 @@ mod tests {
|
|||||||
st.accessible = true;
|
st.accessible = true;
|
||||||
st.show_index = false;
|
st.show_index = false;
|
||||||
let resp = st.handle(HttpRequest::default())
|
let resp = st.handle(HttpRequest::default())
|
||||||
.respond_to(HttpRequest::default())
|
.respond_to(&HttpRequest::default())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let resp = resp.as_msg();
|
let resp = resp.as_msg();
|
||||||
assert_eq!(resp.status(), StatusCode::NOT_FOUND);
|
assert_eq!(resp.status(), StatusCode::NOT_FOUND);
|
||||||
@ -783,7 +783,7 @@ mod tests {
|
|||||||
|
|
||||||
st.show_index = true;
|
st.show_index = true;
|
||||||
let resp = st.handle(req)
|
let resp = st.handle(req)
|
||||||
.respond_to(HttpRequest::default())
|
.respond_to(&HttpRequest::default())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let resp = resp.as_msg();
|
let resp = resp.as_msg();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
@ -801,7 +801,7 @@ mod tests {
|
|||||||
req.match_info_mut().add("tail", "tests");
|
req.match_info_mut().add("tail", "tests");
|
||||||
|
|
||||||
let resp = st.handle(req)
|
let resp = st.handle(req)
|
||||||
.respond_to(HttpRequest::default())
|
.respond_to(&HttpRequest::default())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let resp = resp.as_msg();
|
let resp = resp.as_msg();
|
||||||
assert_eq!(resp.status(), StatusCode::FOUND);
|
assert_eq!(resp.status(), StatusCode::FOUND);
|
||||||
@ -814,7 +814,7 @@ mod tests {
|
|||||||
req.match_info_mut().add("tail", "tests/");
|
req.match_info_mut().add("tail", "tests/");
|
||||||
|
|
||||||
let resp = st.handle(req)
|
let resp = st.handle(req)
|
||||||
.respond_to(HttpRequest::default())
|
.respond_to(&HttpRequest::default())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let resp = resp.as_msg();
|
let resp = resp.as_msg();
|
||||||
assert_eq!(resp.status(), StatusCode::FOUND);
|
assert_eq!(resp.status(), StatusCode::FOUND);
|
||||||
@ -831,7 +831,7 @@ mod tests {
|
|||||||
req.match_info_mut().add("tail", "tools/wsload");
|
req.match_info_mut().add("tail", "tools/wsload");
|
||||||
|
|
||||||
let resp = st.handle(req)
|
let resp = st.handle(req)
|
||||||
.respond_to(HttpRequest::default())
|
.respond_to(&HttpRequest::default())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let resp = resp.as_msg();
|
let resp = resp.as_msg();
|
||||||
assert_eq!(resp.status(), StatusCode::FOUND);
|
assert_eq!(resp.status(), StatusCode::FOUND);
|
||||||
|
@ -1057,7 +1057,7 @@ mod tests {
|
|||||||
assert_eq!(resp.status(), StatusCode::OK);
|
assert_eq!(resp.status(), StatusCode::OK);
|
||||||
assert_eq!(resp.body().binary().unwrap(), &Binary::from("test"));
|
assert_eq!(resp.body().binary().unwrap(), &Binary::from("test"));
|
||||||
|
|
||||||
let resp: HttpResponse = "test".respond_to(req.clone()).ok().unwrap();
|
let resp: HttpResponse = "test".respond_to(&req).ok().unwrap();
|
||||||
assert_eq!(resp.status(), StatusCode::OK);
|
assert_eq!(resp.status(), StatusCode::OK);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resp.headers().get(CONTENT_TYPE).unwrap(),
|
resp.headers().get(CONTENT_TYPE).unwrap(),
|
||||||
@ -1078,7 +1078,7 @@ mod tests {
|
|||||||
&Binary::from(b"test".as_ref())
|
&Binary::from(b"test".as_ref())
|
||||||
);
|
);
|
||||||
|
|
||||||
let resp: HttpResponse = b"test".as_ref().respond_to(req.clone()).ok().unwrap();
|
let resp: HttpResponse = b"test".as_ref().respond_to(&req).ok().unwrap();
|
||||||
assert_eq!(resp.status(), StatusCode::OK);
|
assert_eq!(resp.status(), StatusCode::OK);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resp.headers().get(CONTENT_TYPE).unwrap(),
|
resp.headers().get(CONTENT_TYPE).unwrap(),
|
||||||
@ -1102,11 +1102,7 @@ mod tests {
|
|||||||
&Binary::from("test".to_owned())
|
&Binary::from("test".to_owned())
|
||||||
);
|
);
|
||||||
|
|
||||||
let resp: HttpResponse = "test"
|
let resp: HttpResponse = "test".to_owned().respond_to(&req).ok().unwrap();
|
||||||
.to_owned()
|
|
||||||
.respond_to(req.clone())
|
|
||||||
.ok()
|
|
||||||
.unwrap();
|
|
||||||
assert_eq!(resp.status(), StatusCode::OK);
|
assert_eq!(resp.status(), StatusCode::OK);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resp.headers().get(CONTENT_TYPE).unwrap(),
|
resp.headers().get(CONTENT_TYPE).unwrap(),
|
||||||
@ -1130,10 +1126,7 @@ mod tests {
|
|||||||
&Binary::from(&"test".to_owned())
|
&Binary::from(&"test".to_owned())
|
||||||
);
|
);
|
||||||
|
|
||||||
let resp: HttpResponse = (&"test".to_owned())
|
let resp: HttpResponse = (&"test".to_owned()).respond_to(&req).ok().unwrap();
|
||||||
.respond_to(req.clone())
|
|
||||||
.ok()
|
|
||||||
.unwrap();
|
|
||||||
assert_eq!(resp.status(), StatusCode::OK);
|
assert_eq!(resp.status(), StatusCode::OK);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resp.headers().get(CONTENT_TYPE).unwrap(),
|
resp.headers().get(CONTENT_TYPE).unwrap(),
|
||||||
@ -1159,7 +1152,7 @@ mod tests {
|
|||||||
);
|
);
|
||||||
|
|
||||||
let b = Bytes::from_static(b"test");
|
let b = Bytes::from_static(b"test");
|
||||||
let resp: HttpResponse = b.respond_to(req.clone()).ok().unwrap();
|
let resp: HttpResponse = b.respond_to(&req).ok().unwrap();
|
||||||
assert_eq!(resp.status(), StatusCode::OK);
|
assert_eq!(resp.status(), StatusCode::OK);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resp.headers().get(CONTENT_TYPE).unwrap(),
|
resp.headers().get(CONTENT_TYPE).unwrap(),
|
||||||
@ -1185,7 +1178,7 @@ mod tests {
|
|||||||
);
|
);
|
||||||
|
|
||||||
let b = BytesMut::from("test");
|
let b = BytesMut::from("test");
|
||||||
let resp: HttpResponse = b.respond_to(req.clone()).ok().unwrap();
|
let resp: HttpResponse = b.respond_to(&req).ok().unwrap();
|
||||||
assert_eq!(resp.status(), StatusCode::OK);
|
assert_eq!(resp.status(), StatusCode::OK);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resp.headers().get(CONTENT_TYPE).unwrap(),
|
resp.headers().get(CONTENT_TYPE).unwrap(),
|
||||||
|
Loading…
Reference in New Issue
Block a user