1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-12-24 00:50:36 +00:00

tests: test passthrough of unsupported req/res types

This commit is contained in:
axon-q 2018-06-14 11:44:48 +00:00
parent 77e5f6a99b
commit 2e883cf44f

View file

@ -319,6 +319,37 @@ mod tests {
assert_eq!(res.status(), StatusCode::NOT_MODIFIED); assert_eq!(res.status(), StatusCode::NOT_MODIFIED);
} }
#[test] #[test]
fn test_unsupported_messages_unchanged() {
use http;
use Body;
let mut eh = EtagHasher::new(DefaultHasher::new(), DefaultFilter);
let mut req = TestRequest::default().method(http::Method::HEAD).finish();
let res = HttpResponse::Ok().body(TEST_BODY);
let res = mwres(eh.response(&mut req, res));
assert!(res.headers().get(ETAG).is_none());
let mut req = TestRequest::default().method(http::Method::POST).finish();
let res = HttpResponse::Ok().body(TEST_BODY);
let res = mwres(eh.response(&mut req, res));
assert!(res.headers().get(ETAG).is_none());
let mut req = TestRequest::default().method(http::Method::PUT).finish();
let res = HttpResponse::Ok().body(TEST_BODY);
let res = mwres(eh.response(&mut req, res));
assert!(res.headers().get(ETAG).is_none());
let mut req = TestRequest::default().method(http::Method::PATCH).finish();
let res = HttpResponse::Ok().body(TEST_BODY);
let res = mwres(eh.response(&mut req, res));
assert!(res.headers().get(ETAG).is_none());
let mut req = TestRequest::default().method(http::Method::GET).finish();
let res = HttpResponse::Ok().body(Body::Empty);
let res = mwres(eh.response(&mut req, res));
assert!(res.headers().get(ETAG).is_none());
}
#[test]
fn test_custom_match() { fn test_custom_match() {
let mut eh = EtagHasher::new( let mut eh = EtagHasher::new(
|_input: &[u8]| "static".to_string(), |_input: &[u8]| "static".to_string(),