test: Add timeouts to HTTP POST tests

Occasionally (and seemingly most commonly in travis-ci), httpbin does
not respond to POST requests.
This commit is contained in:
Vincent Ambo 2019-02-26 17:58:20 +01:00
parent cf58060fcc
commit a039908fc4

View file

@ -44,6 +44,7 @@ fn test_http_post() {
let body = "test body";
let response = Request::new(Method::Post, "https://httpbin.org/post")
.user_agent("crimp test suite").expect("failed to set user-agent")
.timeout(Duration::from_secs(5)).expect("failed to set request timeout")
.body("text/plain", &body.as_bytes())
.send().expect("failed to send request")
.as_json::<Value>().expect("failed to deserialize response");
@ -70,6 +71,7 @@ fn test_http_post_json() {
let response = Request::new(Method::Post, "https://httpbin.org/post")
.user_agent("crimp test suite").expect("failed to set user-agent")
.timeout(Duration::from_secs(5)).expect("failed to set request timeout")
.json(&body).expect("request serialization failed")
.send().expect("failed to send request")
.as_json::<Value>().expect("failed to deserialize response");