[njs] Tests: fixed js tests for Fetch API for nginx-1.22 and below.
Dmitry Volyntsev
xeioex at nginx.com
Tue Jun 6 01:31:35 UTC 2023
details: https://hg.nginx.org/njs/rev/db36e0384d97
branches:
changeset: 2146:db36e0384d97
user: Dmitry Volyntsev <xeioex at nginx.com>
date: Mon Feb 06 09:36:13 2023 -0800
description:
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.
diffstat:
nginx/t/js_fetch_objects.t | 30 +++++++++++++++++++++++++-----
1 files changed, 25 insertions(+), 5 deletions(-)
diffs (67 lines):
diff -r d73bfec720b9 -r db36e0384d97 nginx/t/js_fetch_objects.t
--- a/nginx/t/js_fetch_objects.t Thu Jun 01 09:39:27 2023 -0700
+++ b/nginx/t/js_fetch_objects.t Mon Feb 06 09:36:13 2023 -0800
@@ -61,6 +61,10 @@ http {
js_content test.fetch;
}
+ location /fetch_multi_header {
+ js_content test.fetch_multi_header;
+ }
+
location /method {
return 200 $request_method;
}
@@ -450,13 +454,20 @@ my $p0 = port(8080);
var body = await r.text();
return `\${r.url}: \${r.status} \${body}`;
}, 'http://127.0.0.1:$p0/body: 201 foo'],
- ['request body', async () => {
+ ];
+
+ run(r, tests);
+ }
+
+ async function fetch_multi_header(r) {
+ const tests = [
+ ['request multi header', async () => {
var h = new Headers({a: 'X'});
h.append('a', 'Z');
var req = new Request("http://127.0.0.1:$p0/header",
{headers: h});
- var r = await ngx.fetch(req);
- var body = await r.text();
+ var r = await ngx.fetch(req);
+ var body = await r.text();
return `\${r.url}: \${r.status} \${body}`;
}, 'http://127.0.0.1:$p0/header: 200 X, Z'],
];
@@ -464,10 +475,11 @@ my $p0 = port(8080);
run(r, tests);
}
- export default {njs: test_njs, body, headers, request, response, fetch};
+ export default {njs: test_njs, body, headers, request, response, fetch,
+ fetch_multi_header};
EOF
-$t->try_run('no njs')->plan(4);
+$t->try_run('no njs')->plan(5);
###############################################################################
@@ -478,6 +490,14 @@ like(http_get('/request'), qr/200 OK/s,
like(http_get('/response'), qr/200 OK/s, 'response tests');
like(http_get('/fetch'), qr/200 OK/s, 'fetch tests');
+TODO: {
+local $TODO = 'not yet' unless $t->has_version('1.23.0');
+
+like(http_get('/fetch_multi_header'), qr/200 OK/s,
+ 'fetch multi header tests');
+
+}
+
###############################################################################
sub has_version {
More information about the nginx-devel
mailing list