From 03d6b04eefab2aa65f5c0ea40a191a4c7ea70fa3 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Fri, 4 May 2018 12:11:38 -0700 Subject: [PATCH] update tests --- src/fs.rs | 24 ++++++++++++------------ src/httpresponse.rs | 19 ++++++------------- 2 files changed, 18 insertions(+), 25 deletions(-) diff --git a/src/fs.rs b/src/fs.rs index de1a60a3..bb808ab7 100644 --- a/src/fs.rs +++ b/src/fs.rs @@ -650,7 +650,7 @@ mod tests { let _f: &mut File = &mut file; } - let resp = file.respond_to(HttpRequest::default()).unwrap(); + let resp = file.respond_to(&HttpRequest::default()).unwrap(); assert_eq!( resp.headers().get(header::CONTENT_TYPE).unwrap(), "text/x-toml" @@ -676,7 +676,7 @@ mod tests { let _f: &mut File = &mut file; } - let resp = file.respond_to(HttpRequest::default()).unwrap(); + let resp = file.respond_to(&HttpRequest::default()).unwrap(); assert_eq!( resp.headers().get(header::CONTENT_TYPE).unwrap(), "image/png" @@ -702,7 +702,7 @@ mod tests { let _f: &mut File = &mut file; } - let resp = file.respond_to(HttpRequest::default()).unwrap(); + let resp = file.respond_to(&HttpRequest::default()).unwrap(); assert_eq!( resp.headers().get(header::CONTENT_TYPE).unwrap(), "application/octet-stream" @@ -729,7 +729,7 @@ mod tests { let _f: &mut File = &mut file; } - let resp = file.respond_to(HttpRequest::default()).unwrap(); + let resp = file.respond_to(&HttpRequest::default()).unwrap(); assert_eq!( resp.headers().get(header::CONTENT_TYPE).unwrap(), "text/x-toml" @@ -748,7 +748,7 @@ mod tests { let req = TestRequest::default().method(Method::POST).finish(); 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); } @@ -756,7 +756,7 @@ mod tests { fn test_named_file_any_method() { let req = TestRequest::default().method(Method::POST).finish(); 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); } @@ -765,7 +765,7 @@ mod tests { let mut st = StaticFiles::new(".").show_files_listing(); st.accessible = false; let resp = st.handle(HttpRequest::default()) - .respond_to(HttpRequest::default()) + .respond_to(&HttpRequest::default()) .unwrap(); let resp = resp.as_msg(); assert_eq!(resp.status(), StatusCode::NOT_FOUND); @@ -773,7 +773,7 @@ mod tests { st.accessible = true; st.show_index = false; let resp = st.handle(HttpRequest::default()) - .respond_to(HttpRequest::default()) + .respond_to(&HttpRequest::default()) .unwrap(); let resp = resp.as_msg(); assert_eq!(resp.status(), StatusCode::NOT_FOUND); @@ -783,7 +783,7 @@ mod tests { st.show_index = true; let resp = st.handle(req) - .respond_to(HttpRequest::default()) + .respond_to(&HttpRequest::default()) .unwrap(); let resp = resp.as_msg(); assert_eq!( @@ -801,7 +801,7 @@ mod tests { req.match_info_mut().add("tail", "tests"); let resp = st.handle(req) - .respond_to(HttpRequest::default()) + .respond_to(&HttpRequest::default()) .unwrap(); let resp = resp.as_msg(); assert_eq!(resp.status(), StatusCode::FOUND); @@ -814,7 +814,7 @@ mod tests { req.match_info_mut().add("tail", "tests/"); let resp = st.handle(req) - .respond_to(HttpRequest::default()) + .respond_to(&HttpRequest::default()) .unwrap(); let resp = resp.as_msg(); assert_eq!(resp.status(), StatusCode::FOUND); @@ -831,7 +831,7 @@ mod tests { req.match_info_mut().add("tail", "tools/wsload"); let resp = st.handle(req) - .respond_to(HttpRequest::default()) + .respond_to(&HttpRequest::default()) .unwrap(); let resp = resp.as_msg(); assert_eq!(resp.status(), StatusCode::FOUND); diff --git a/src/httpresponse.rs b/src/httpresponse.rs index 00db2775..8097fc93 100644 --- a/src/httpresponse.rs +++ b/src/httpresponse.rs @@ -1057,7 +1057,7 @@ mod tests { assert_eq!(resp.status(), StatusCode::OK); 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.headers().get(CONTENT_TYPE).unwrap(), @@ -1078,7 +1078,7 @@ mod tests { &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.headers().get(CONTENT_TYPE).unwrap(), @@ -1102,11 +1102,7 @@ mod tests { &Binary::from("test".to_owned()) ); - let resp: HttpResponse = "test" - .to_owned() - .respond_to(req.clone()) - .ok() - .unwrap(); + let resp: HttpResponse = "test".to_owned().respond_to(&req).ok().unwrap(); assert_eq!(resp.status(), StatusCode::OK); assert_eq!( resp.headers().get(CONTENT_TYPE).unwrap(), @@ -1130,10 +1126,7 @@ mod tests { &Binary::from(&"test".to_owned()) ); - let resp: HttpResponse = (&"test".to_owned()) - .respond_to(req.clone()) - .ok() - .unwrap(); + let resp: HttpResponse = (&"test".to_owned()).respond_to(&req).ok().unwrap(); assert_eq!(resp.status(), StatusCode::OK); assert_eq!( resp.headers().get(CONTENT_TYPE).unwrap(), @@ -1159,7 +1152,7 @@ mod tests { ); 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.headers().get(CONTENT_TYPE).unwrap(), @@ -1185,7 +1178,7 @@ mod tests { ); 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.headers().get(CONTENT_TYPE).unwrap(),