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:
parent
cf58060fcc
commit
a039908fc4
1 changed files with 2 additions and 0 deletions
|
@ -44,6 +44,7 @@ fn test_http_post() {
|
||||||
let body = "test body";
|
let body = "test body";
|
||||||
let response = Request::new(Method::Post, "https://httpbin.org/post")
|
let response = Request::new(Method::Post, "https://httpbin.org/post")
|
||||||
.user_agent("crimp test suite").expect("failed to set user-agent")
|
.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())
|
.body("text/plain", &body.as_bytes())
|
||||||
.send().expect("failed to send request")
|
.send().expect("failed to send request")
|
||||||
.as_json::<Value>().expect("failed to deserialize response");
|
.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")
|
let response = Request::new(Method::Post, "https://httpbin.org/post")
|
||||||
.user_agent("crimp test suite").expect("failed to set user-agent")
|
.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")
|
.json(&body).expect("request serialization failed")
|
||||||
.send().expect("failed to send request")
|
.send().expect("failed to send request")
|
||||||
.as_json::<Value>().expect("failed to deserialize response");
|
.as_json::<Value>().expect("failed to deserialize response");
|
||||||
|
|
Loading…
Reference in a new issue