Mercurial > hg > nginx-tests
changeset 1614:bc0990ea2e5b
Tests: js TODO adjusted up to 0.4.0.
author | Dmitry Volyntsev <xeioex@nginx.com> |
---|---|
date | Tue, 17 Nov 2020 17:49:16 +0000 |
parents | d7ec131d305a |
children | 4eb2a82dd9b5 |
files | js.t js_dump.t js_internal_redirect.t js_modules.t js_object.t js_paths.t js_promise.t js_request_body.t js_return.t js_subrequests.t js_variables.t stream_js_object.t stream_js_variables.t |
diffstat | 13 files changed, 2 insertions(+), 170 deletions(-) [+] |
line wrap: on
line diff
--- a/js.t Tue Nov 17 17:39:11 2020 +0300 +++ b/js.t Tue Nov 17 17:49:16 2020 +0000 @@ -244,7 +244,6 @@ ############################################################################### - like(http_get('/method'), qr/method=GET/, 'r.method'); like(http_get('/version'), qr/version=1.0/, 'r.httpVersion'); like(http_get('/addr'), qr/addr=127.0.0.1/, 'r.remoteAddress'); @@ -278,14 +277,8 @@ like(http_get('/return_method?c=404'), qr/404 Not.*html/s, 'return error page'); like(http_get('/return_method?c=inv'), qr/ 500 /, 'return invalid'); -TODO: { -local $TODO = 'not yet' - unless http_get('/njs') =~ /^([.0-9]+)$/m && $1 ge '0.3.7'; - like(http_get('/arg_keys?b=1&c=2&a=5'), qr/a,b,c/m, 'r.args sorted keys'); -} - like(http_get('/var'), qr/variable=127.0.0.1/, 'r.variables'); like(http_get('/global'), qr/global=njs/, 'global code'); like(http_get('/log'), qr/200 OK/, 'r.log');
--- a/js_dump.t Tue Nov 17 17:39:11 2020 +0300 +++ b/js_dump.t Tue Nov 17 17:49:16 2020 +0000 @@ -42,10 +42,6 @@ listen 127.0.0.1:8080; server_name localhost; - location /njs { - js_content test_njs; - } - location /dump { js_content test_dump; } @@ -67,10 +63,6 @@ EOF $t->write_file('test.js', <<EOF); - function test_njs(r) { - r.return(200, njs.version); - } - function test_dump(r) { r.headersOut.baz = 'bar'; r.return(200, njs.dump(r)); @@ -94,10 +86,6 @@ ############################################################################### -TODO: { -local $TODO = 'not yet' - unless http_get('/njs') =~ /^([.0-9]+)$/m && $1 ge '0.3.8'; - like(http( 'GET /dump?v=1&t=x HTTP/1.0' . CRLF . 'Foo: bar' . CRLF @@ -117,6 +105,4 @@ . 'Host: localhost' . CRLF . CRLF ), qr/responseBody":"\{GET}"/, 'JSON.stringify(reply)'); -} - ###############################################################################
--- a/js_internal_redirect.t Tue Nov 17 17:39:11 2020 +0300 +++ b/js_internal_redirect.t Tue Nov 17 17:49:16 2020 +0000 @@ -41,10 +41,6 @@ listen 127.0.0.1:8080; server_name localhost; - location /njs { - js_content test_njs; - } - location /test { js_content test_redirect; } @@ -63,10 +59,6 @@ EOF $t->write_file('test.js', <<EOF); - function test_njs(r) { - r.return(200, njs.version); - } - function test_redirect(r) { if (r.variables.arg_dest == 'named') { r.internalRedirect('\@named');
--- a/js_modules.t Tue Nov 17 17:39:11 2020 +0300 +++ b/js_modules.t Tue Nov 17 17:49:16 2020 +0000 @@ -41,10 +41,6 @@ listen 127.0.0.1:8080; server_name localhost; - location /njs { - js_content test_njs; - } - location /test { js_content test; } @@ -56,10 +52,6 @@ $t->write_file('test.js', <<EOF); import m from 'module.js'; - function test_njs(r) { - r.return(200, njs.version); - } - function test(r) { r.return(200, m[r.args.fun](r.args.a, r.args.b)); }
--- a/js_object.t Tue Nov 17 17:39:11 2020 +0300 +++ b/js_object.t Tue Nov 17 17:49:16 2020 +0000 @@ -42,10 +42,6 @@ listen 127.0.0.1:8080; server_name localhost; - location /njs { - js_content test_njs; - } - location /to_string { js_content to_string; } @@ -79,10 +75,6 @@ EOF $t->write_file('test.js', <<EOF); - function test_njs(r) { - r.return(200, njs.version); - } - function to_string(r) { r.return(200, r.toString()); } @@ -127,11 +119,6 @@ ############################################################################### -TODO: { -local $TODO = 'not yet' - unless http_get('/njs') =~ /^([.0-9]+)$/m && $1 ge '0.4.0'; - - like(http_get('/to_string'), qr/\[object Request\]/, 'toString'); like(http_get('/define_prop'), qr/Foo: bar/, 'define_prop'); like(http( @@ -144,6 +131,4 @@ like(http_get('/redefine_proto'), qr/a|b/, 'redefine_proto'); like(http_get('/get_own_prop_descs'), qr/true/, 'get_own_prop_descs'); -} - ###############################################################################
--- a/js_paths.t Tue Nov 17 17:39:11 2020 +0300 +++ b/js_paths.t Tue Nov 17 17:49:16 2020 +0000 @@ -44,10 +44,6 @@ listen 127.0.0.1:8080; server_name localhost; - location /njs { - js_content test_njs; - } - location /test { js_content test; } @@ -65,10 +61,6 @@ import m2 from 'module2.js'; import m3 from 'lib1/module1.js'; - function test_njs(r) { - r.return(200, njs.version); - } - function test(r) { r.return(200, m1[r.args.fun](r.args.a, r.args.b)); }
--- a/js_promise.t Tue Nov 17 17:39:11 2020 +0300 +++ b/js_promise.t Tue Nov 17 17:49:16 2020 +0000 @@ -55,10 +55,6 @@ location /sub_token { js_content sub_token; } - - location /njs { - js_content test_njs; - } } } @@ -164,24 +160,14 @@ r.return(parseInt(code), '{"token": "'+ token +'"}'); } - function test_njs(r) { - r.return(200, njs.version); - } - EOF $t->try_run('no njs available')->plan(3); ############################################################################### -TODO: { -local $TODO = 'not yet' - unless http_get('/njs') =~ /^([.0-9]+)$/m && $1 ge '0.3.8'; - like(http_get('/promise'), qr/{"token": "b"}/, "Promise"); like(http_get('/promise_throw'), qr/{"token": "x"}/, "Promise throw and catch"); like(http_get('/timeout'), qr/{"token": "R"}/, "Promise with timeout"); -} - ###############################################################################
--- a/js_request_body.t Tue Nov 17 17:39:11 2020 +0300 +++ b/js_request_body.t Tue Nov 17 17:49:16 2020 +0000 @@ -43,10 +43,6 @@ listen 127.0.0.1:8080; server_name localhost; - location /njs { - js_content test_njs; - } - location /body { js_content test_body; } @@ -61,10 +57,6 @@ EOF $t->write_file('test.js', <<EOF); - function test_njs(r) { - r.return(200, njs.version); - } - function test_body(r) { try { var body = r.requestBody;
--- a/js_return.t Tue Nov 17 17:39:11 2020 +0300 +++ b/js_return.t Tue Nov 17 17:49:16 2020 +0000 @@ -43,10 +43,6 @@ listen 127.0.0.1:8080; server_name localhost; - location /njs { - js_content test_njs; - } - location / { js_content test_return; } @@ -56,10 +52,6 @@ EOF $t->write_file('test.js', <<EOF); - function test_njs(r) { - r.return(200, njs.version); - } - function test_return(r) { r.return(Number(r.args.c), r.args.t); }
--- a/js_subrequests.t Tue Nov 17 17:39:11 2020 +0300 +++ b/js_subrequests.t Tue Nov 17 17:49:16 2020 +0000 @@ -52,10 +52,6 @@ listen 127.0.0.1:8080; server_name localhost; - location /njs { - js_content test_njs; - } - location /sr { js_content sr; } @@ -259,10 +255,6 @@ $t->write_file('test.js', <<EOF); this.Failed = {get toConvert() { return {toString(){return {};}}}}; - function test_njs(r) { - r.return(200, njs.version); - } - function sr(r) { subrequest_fn(r, ['/p/sub2'], ['uri', 'status']) } @@ -518,12 +510,6 @@ '{"status":200,"uri":"/p/delayed"}]', 'sr_multi'); -my $ver = http_get('/njs'); - -TODO: { -local $TODO = 'not yet' - unless $ver =~ /^([.0-9]+)$/m && $1 ge '0.3.8'; - is(get_json('/sr_pr'), '{"h":"xxx"}', 'sr_promise'); is(get_json('/sr_options_args_pr'), '{"h":"xxx"}', 'sr_options_args_pr'); is(get_json('/sr_options_method_pr?m=PUT'), '["PUT"]', 'sr method PUT'); @@ -532,15 +518,8 @@ is(get_json('/sr_unavail_pr'), '[{"status":502,"uri":"/unavail"}]', 'sr_unavail_pr'); -} - -TODO: { -local $TODO = 'not yet' - unless $ver =~ /^([.0-9]+)$/m && $1 ge '0.3.9'; - like(http_get('/sr_detached_in_variable_handler'), qr/subrequest_var/, 'sr_detached_in_variable_handler'); -} http_get('/sr_broken'); http_get('/sr_in_sr'); @@ -571,13 +550,8 @@ 'js subrequest: failed to get the parent context') > 0, 'zero parent ctx'); -TODO: { -local $TODO = 'not yet' - unless $ver =~ /^([.0-9]+)$/m && $1 ge '0.3.9'; - ok(index($t->read_file('error.log'), 'DETACHED') > 0, 'detached subrequest'); -} ###############################################################################
--- a/js_variables.t Tue Nov 17 17:39:11 2020 +0300 +++ b/js_variables.t Tue Nov 17 17:49:16 2020 +0000 @@ -45,10 +45,6 @@ set $foo foo_orig; - location /njs { - js_content test_njs; - } - location /var_set { return 200 $test_var$foo; } @@ -66,10 +62,6 @@ EOF $t->write_file('test.js', <<EOF); - function test_njs(r) { - r.return(200, njs.version); - } - function test_var(r) { r.variables.foo = r.variables.arg_a; return 'test_var';
--- a/stream_js_object.t Tue Nov 17 17:39:11 2020 +0300 +++ b/stream_js_object.t Tue Nov 17 17:49:16 2020 +0000 @@ -23,7 +23,7 @@ select STDERR; $| = 1; select STDOUT; $| = 1; -my $t = Test::Nginx->new()->has(qw/http stream stream_return/) +my $t = Test::Nginx->new()->has(qw/stream stream_return/) ->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%% @@ -33,21 +33,6 @@ events { } -http { - %%TEST_GLOBALS_HTTP%% - - js_include test.js; - - server { - listen 127.0.0.1:8080; - server_name localhost; - - location /njs { - js_content test_njs; - } - } -} - stream { %%TEST_GLOBALS_STREAM%% @@ -64,10 +49,6 @@ EOF $t->write_file('test.js', <<EOF); - function test_njs(r) { - r.return(200, njs.version); - } - function to_string(s) { return s.toString() === '[object Stream Session]'; } @@ -110,12 +91,6 @@ ############################################################################### -TODO: { -local $TODO = 'not yet' - unless http_get('/njs') =~ /^([.0-9]+)$/m && $1 ge '0.4.0'; - is(stream('127.0.0.1:' . port(8081))->read(), 'true400', 'var set'); -} - ###############################################################################
--- a/stream_js_variables.t Tue Nov 17 17:39:11 2020 +0300 +++ b/stream_js_variables.t Tue Nov 17 17:49:16 2020 +0000 @@ -23,7 +23,7 @@ select STDERR; $| = 1; select STDOUT; $| = 1; -my $t = Test::Nginx->new()->has(qw/http stream stream_return/) +my $t = Test::Nginx->new()->has(qw/stream stream_return/) ->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%% @@ -33,21 +33,6 @@ events { } -http { - %%TEST_GLOBALS_HTTP%% - - js_include test.js; - - server { - listen 127.0.0.1:8080; - server_name localhost; - - location /njs { - js_content test_njs; - } - } -} - stream { %%TEST_GLOBALS_STREAM%% @@ -70,10 +55,6 @@ EOF $t->write_file('test.js', <<EOF); - function test_njs(r) { - r.return(200, njs.version); - } - function test_var(s) { s.variables.status = 400; return 'test_var';