Skip to content

Commit bdd36e1

Browse files
committed
Tests: fixed js tests for Fetch API for nginx-1.22 and below.
The fix is to move a test with multiple headers returned by $http_a variable under an nginx version check.
1 parent b1cda14 commit bdd36e1

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

js_fetch_objects.t

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ http {
6161
js_content test.fetch;
6262
}
6363
64+
location /fetch_multi_header {
65+
js_content test.fetch_multi_header;
66+
}
67+
6468
location /method {
6569
return 200 $request_method;
6670
}
@@ -489,24 +493,32 @@ $t->write_file('test.js', <<EOF);
489493
var body = await r.text();
490494
return `\${r.url}: \${r.status} \${body}`;
491495
}, 'http://127.0.0.1:$p0/body: 201 foo'],
492-
['request body', async () => {
496+
];
497+
498+
run(r, tests);
499+
}
500+
501+
async function fetch_multi_header(r) {
502+
const tests = [
503+
['request multi header', async () => {
493504
var h = new Headers({a: 'X'});
494505
h.append('a', 'Z');
495506
var req = new Request("http://127.0.0.1:$p0/header",
496507
{headers: h});
497-
var r = await ngx.fetch(req);
498-
var body = await r.text();
508+
var r = await ngx.fetch(req);
509+
var body = await r.text();
499510
return `\${r.url}: \${r.status} \${body}`;
500511
}, 'http://127.0.0.1:$p0/header: 200 X, Z'],
501512
];
502513
503514
run(r, tests);
504515
}
505516
506-
export default {njs: test_njs, body, headers, request, response, fetch};
517+
export default {njs: test_njs, body, headers, request, response, fetch,
518+
fetch_multi_header};
507519
EOF
508520

509-
$t->try_run('no njs')->plan(4);
521+
$t->try_run('no njs')->plan(5);
510522

511523
###############################################################################
512524

@@ -517,6 +529,14 @@ like(http_get('/request'), qr/200 OK/s, 'request tests');
517529
like(http_get('/response'), qr/200 OK/s, 'response tests');
518530
like(http_get('/fetch'), qr/200 OK/s, 'fetch tests');
519531

532+
TODO: {
533+
local $TODO = 'not yet' unless $t->has_version('1.23.0');
534+
535+
like(http_get('/fetch_multi_header'), qr/200 OK/s,
536+
'fetch multi header tests');
537+
538+
}
539+
520540
###############################################################################
521541

522542
sub has_version {

0 commit comments

Comments
 (0)