Skip to content

Commit

Permalink
'fix': fetchpost --content-type tests now that it validates `applic…
Browse files Browse the repository at this point in the history
…ation/json` and `application/x-www-form-urlencoded` when `--content-type` is set
  • Loading branch information
jqnatividad committed Nov 5, 2024
1 parent 054f7f6 commit 44e5115
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions tests/test_fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1738,19 +1738,19 @@ fn fetchpost_content_type() {
.arg("payload.tpl")
.arg("--content-type")
.arg("text/plain")
.arg("--jaq")
.arg(r#"."data""#)
.arg("data.csv");

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

// Create JSON template file
wrk.create_from_string(
"jsonpayload.tpl",
r#"{
"URL": "{{ URL }}",
"Message": "{{ message }}",
"Message": "{{ message }}"
}"#,
);

Expand All @@ -1768,7 +1768,7 @@ fn fetchpost_content_type() {
let got = wrk.stdout::<String>(&mut cmd);
assert_eq!(
got,
"\"{\n \"URL\": \"https://httpbin.org/post\",\n \"Message\": \"Hello World\",\n}\""
r#"{"Message":"Hello World","URL":"https://httpbin.org/post"}"#
);

// Test form data content type
Expand All @@ -1780,5 +1780,5 @@ fn fetchpost_content_type() {
.arg("data.csv");

let got = wrk.stdout::<String>(&mut cmd);
assert_eq!(got, "{\"message\":\"Hello World\"}");
assert_eq!(got, r#"{"message":"Hello World"}"#);
}

0 comments on commit 44e5115

Please sign in to comment.