Skip to content

Commit 9762f4c

Browse files
committed
Merge pull request Kong#20 from thibaultCha/tests/application-json
tests: stronger application-json.json fixture
2 parents 9d98fc0 + d470acd commit 9762f4c

11 files changed

Lines changed: 43 additions & 11 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
curl --request POST \
22
--url "http://mockbin.com/har" \
33
--header "content-type: application/json" \
4-
--data "{\"foo\": \"bar\"}"
4+
--data "{\"number\": 1, \"string\": \"f\\\"oo\", \"arr\": [1, 2, 3], \"nested\": {\"a\": \"b\"}, \"arr_mix\": [1, \"a\", {\"arr_mix_nested\": {}}] }"

‎test/fixtures/output/go/native/application-json.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
func main() {
1111
client := &http.Client{}
1212
url := "http://mockbin.com/har"
13-
payload := "{\"foo\": \"bar\"}"
13+
payload := "{\"number\": 1, \"string\": \"f\\\"oo\", \"arr\": [1, 2, 3], \"nested\": {\"a\": \"b\"}, \"arr_mix\": [1, \"a\", {\"arr_mix_nested\": {}}] }"
1414
req, _ := http.NewRequest("POST", url, strings.NewReader(payload))
1515
req.Header.Add("content-type", "application/json")
1616
res, _ := client.Do(req)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
echo "{\"foo\": \"bar\"}" | \
1+
echo "{\"number\": 1, \"string\": \"f\\\"oo\", \"arr\": [1, 2, 3], \"nested\": {\"a\": \"b\"}, \"arr_mix\": [1, \"a\", {\"arr_mix_nested\": {}}] }" | \
22
http POST http://mockbin.com/har \
33
content-type:application/json

‎test/fixtures/output/node/native/application-json.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ var req = http.request(options, function (res) {
2323
});
2424
});
2525

26-
req.write("{\"foo\": \"bar\"}");
26+
req.write("{\"number\": 1, \"string\": \"f\\\"oo\", \"arr\": [1, 2, 3], \"nested\": {\"a\": \"b\"}, \"arr_mix\": [1, \"a\", {\"arr_mix_nested\": {}}] }");
2727
req.end();

‎test/fixtures/output/node/request/application-json.js‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,23 @@ request({
77
"content-type": "application/json"
88
},
99
"body": {
10-
"foo": "bar"
10+
"number": 1,
11+
"string": "f\"oo",
12+
"arr": [
13+
1,
14+
2,
15+
3
16+
],
17+
"nested": {
18+
"a": "b"
19+
},
20+
"arr_mix": [
21+
1,
22+
"a",
23+
{
24+
"arr_mix_nested": {}
25+
}
26+
]
1127
},
1228
"json": true
1329
}, function (error, response, body) {

‎test/fixtures/output/node/unirest/application-json.js‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,23 @@ req.headers({
88

99
req.type("json");
1010
req.send({
11-
"foo": "bar"
11+
"number": 1,
12+
"string": "f\"oo",
13+
"arr": [
14+
1,
15+
2,
16+
3
17+
],
18+
"nested": {
19+
"a": "b"
20+
},
21+
"arr_mix": [
22+
1,
23+
"a",
24+
{
25+
"arr_mix_nested": {}
26+
}
27+
]
1228
});
1329

1430
req.end(function (res) {

‎test/fixtures/output/objc/native/application-json.m‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
[request setHTTPMethod:@"POST"];
99
[request setValue:@"application/json" forHTTPHeaderField:@"content-type"];
1010

11-
NSData *postData = [[NSData alloc] initWithData:[@"{\"foo\": \"bar\"}" dataUsingEncoding:NSUTF8StringEncoding]];
11+
NSData *postData = [[NSData alloc] initWithData:[@"{\"number\": 1, \"string\": \"f\\\"oo\", \"arr\": [1, 2, 3], \"nested\": {\"a\": \"b\"}, \"arr_mix\": [1, \"a\", {\"arr_mix_nested\": {}}] }" dataUsingEncoding:NSUTF8StringEncoding]];
1212
[request setHTTPBody:postData];
1313

1414
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request

‎test/fixtures/output/ocaml/cohttp/application-json.ml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ let uri = Uri.of_string "http://mockbin.com/har" in
55
let headers = Header.init ()
66
|> fun h -> Header.add h "content-type" "application/json"
77
in
8-
let body = "{\"foo\": \"bar\"}" in
8+
let body = "{\"number\": 1, \"string\": \"f\\\"oo\", \"arr\": [1, 2, 3], \"nested\": {\"a\": \"b\"}, \"arr_mix\": [1, \"a\", {\"arr_mix_nested\": {}}] }" in
99

1010
Client.call ~headers ~body (Code.method_of_string "POST") uri
1111
>>= fun (res, body_stream) ->

‎test/fixtures/output/php/curl/application-json.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
CURLOPT_TIMEOUT => 30,
1111
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
1212
CURLOPT_CUSTOMREQUEST => "POST",
13-
CURLOPT_POSTFIELDS => "{\"foo\": \"bar\"}",
13+
CURLOPT_POSTFIELDS => "{\"number\": 1, \"string\": \"f\\\"oo\", \"arr\": [1, 2, 3], \"nested\": {\"a\": \"b\"}, \"arr_mix\": [1, \"a\", {\"arr_mix_nested\": {}}] }",
1414
CURLOPT_HTTPHEADER => array(
1515
"content-type: application/json"
1616
),
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
wget --quiet \
22
--method POST \
33
--header "content-type: application/json" \
4-
--body-data "{\"foo\": \"bar\"}" \
4+
--body-data "{\"number\": 1, \"string\": \"f\\\"oo\", \"arr\": [1, 2, 3], \"nested\": {\"a\": \"b\"}, \"arr_mix\": [1, \"a\", {\"arr_mix_nested\": {}}] }" \
55
--output-document \
66
- "http://mockbin.com/har"

0 commit comments

Comments
 (0)