1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-08-30 00:29:29 +02:00

optimize with and with2 method impls and tests

This commit is contained in:
Nikolay Kim
2018-03-28 21:33:40 -07:00
parent 90e3aaaf8a
commit 45dec8d0c0
4 changed files with 142 additions and 25 deletions

View File

@@ -255,8 +255,8 @@ mod tests {
let mut handler = with(|data: Json<MyObject>| data);
let req = HttpRequest::default();
let mut json = handler.handle(req).into_future();
assert!(json.poll().is_err());
let err = handler.handle(req).as_response().unwrap().error().is_some();
assert!(err);
let mut req = HttpRequest::default();
req.headers_mut().insert(header::CONTENT_TYPE,
@@ -264,7 +264,7 @@ mod tests {
req.headers_mut().insert(header::CONTENT_LENGTH,
header::HeaderValue::from_static("16"));
req.payload_mut().unread_data(Bytes::from_static(b"{\"name\": \"test\"}"));
let mut json = handler.handle(req).into_future();
assert!(json.poll().is_ok())
let ok = handler.handle(req).as_response().unwrap().error().is_none();
assert!(ok)
}
}