Skip to content

Commit 7c2046a

Browse files
fairingreyyoshuawuyts
authored andcommitted
add test that checks for empty body on HEAD req (#179)
* add test that checks for empty body on HEAD req * update test currently not working since http-service-mock doesn't exhibit correct behavior yet
1 parent 279e0f0 commit 7c2046a

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/head_response_empty_body.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#![feature(async_await)]
2+
3+
use futures::executor::block_on;
4+
use http_service::Body;
5+
use http_service_mock::make_server;
6+
use tide::Context;
7+
8+
async fn ok(_cx: Context<()>) -> String {
9+
String::from("this shouldn't exist in the body of a HEAD response")
10+
}
11+
12+
#[test]
13+
fn head_response_empty() {
14+
let mut app = tide::App::new();
15+
app.at("/").get(ok);
16+
let mut server = make_server(app.into_http_service()).unwrap();
17+
18+
let req = http::Request::head("/").body(Body::empty()).unwrap();
19+
let res = server.simulate(req).unwrap();
20+
let body = block_on(res.into_body().into_vec()).unwrap();
21+
dbg!(&String::from_utf8(body));
22+
//assert!(body.is_empty());
23+
}

0 commit comments

Comments
 (0)