Skip to content

Commit

Permalink
tests: add assert_success to help debug flaky fetch/fetchpost tests b…
Browse files Browse the repository at this point in the history
…ecause of network issues
  • Loading branch information
jqnatividad committed Dec 2, 2024
1 parent ef0183a commit d9dd382
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/test_fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,8 @@ fn fetch_custom_header() {
.arg(r#"[ ."headers"."X-Api-Key", ."headers"."X-Api-Secret" ]"#)
.arg("data.csv");

wrk.assert_success(&mut cmd);

let got = wrk.stdout::<String>(&mut cmd);
let expected = "[\"DEMO_KEY\",\"ABC123XYZ\"]";
assert_eq!(got, expected);
Expand Down Expand Up @@ -647,6 +649,8 @@ fn fetch_custom_user_agent() {
.arg("Mozilla/5.0 (platform; rv:geckoversion) Gecko/geckotrail Firefox/firefoxversion")
.arg("data.csv");

wrk.assert_success(&mut cmd);

let got = wrk.stdout::<String>(&mut cmd);
assert!(got.contains(
"Mozilla/5.0 (platform; rv:geckoversion) Gecko/geckotrail Firefox/firefoxversion"
Expand Down Expand Up @@ -787,6 +791,8 @@ fn fetchpost_custom_user_agent() {
.arg("Mozilla/5.0 (platform; rv:geckoversion) Gecko/geckotrail Firefox/firefoxversion")
.arg("data.csv");

wrk.assert_success(&mut cmd);

let got = wrk.stdout::<String>(&mut cmd);
assert!(got.contains(
"Mozilla/5.0 (platform; rv:geckoversion) Gecko/geckotrail Firefox/firefoxversion"
Expand Down Expand Up @@ -1072,6 +1078,8 @@ fn fetchpost_simple_test() {
.arg("response")
.arg("data.csv");

wrk.assert_success(&mut cmd);

let got: Vec<Vec<String>> = wrk.read_stdout(&mut cmd);

let mut got_parsed: Vec<Vec<String>> = Vec::new();
Expand Down Expand Up @@ -1405,6 +1413,8 @@ fn fetchpost_literalurl_test() {
.arg("response")
.arg("data.csv");

wrk.assert_success(&mut cmd);

let got: Vec<Vec<String>> = wrk.read_stdout(&mut cmd);

let mut got_parsed: Vec<Vec<String>> = Vec::new();
Expand Down Expand Up @@ -1548,6 +1558,8 @@ fn fetchpost_payload_template() {
.arg(r#"."data""#)
.arg("data.csv");

wrk.assert_success(&mut cmd);

let got: Vec<Vec<String>> = wrk.read_stdout(&mut cmd);

let expected = vec![
Expand Down Expand Up @@ -1614,6 +1626,8 @@ fn fetchpost_payload_template_with_report() {
.arg("short")
.arg("data.csv");

wrk.assert_success(&mut cmd);

let got: Vec<Vec<String>> = wrk.read_stdout(&mut cmd);

let expected = vec![
Expand Down Expand Up @@ -1669,6 +1683,8 @@ fn fetchpost_with_headers() {
.arg(r#"."headers""#)
.arg("data.csv");

wrk.assert_success(&mut cmd);

let got = wrk.stdout::<String>(&mut cmd);
assert!(got.contains("X-Test-Header"));
assert!(got.contains("test123"));
Expand Down Expand Up @@ -1740,6 +1756,8 @@ fn fetchpost_content_type() {
.arg("text/plain")
.arg("data.csv");

wrk.assert_success(&mut cmd);

let got = wrk.stdout::<String>(&mut cmd);
assert!(got.starts_with(
r#"{"args":{},"data":"\"Greeting: Hello World\"","files":{},"form":{},"headers":{"#
Expand Down

0 comments on commit d9dd382

Please sign in to comment.