better test

This commit is contained in:
Martin Algesten
2018-06-30 19:30:32 +02:00
parent 552728d1d1
commit 651c1102c9

View File

@@ -43,14 +43,11 @@ fn agent_cookies() {
assert!(agent.cookie("foo").is_some());
assert_eq!(agent.cookie("foo").unwrap().value(), "bar baz");
test::set_handler("/agent_cookies", |_unit| {
test::set_handler("/agent_cookies", |unit| {
assert!(unit.has("cookie"));
assert_eq!(unit.header("cookie").unwrap(), "foo=bar%20baz");
test::make_response(200, "OK", vec![], vec![])
});
let resp = agent.get("test://host/agent_cookies").call();
let vec = resp.to_write_vec();
let s = String::from_utf8_lossy(&vec);
assert!(s.contains("Cookie: foo=bar%20baz\r\n"));
agent.get("test://host/agent_cookies").call();
}