Mercurial > hg > nginx-tests
comparison js_async.t @ 1751:18ac4d9e5a2a
Tests: rewriting njs tests without deprecated "js_include".
author | Dmitry Volyntsev <xeioex@nginx.com> |
---|---|
date | Thu, 09 Dec 2021 17:36:29 +0000 |
parents | 9e0347f4df11 |
children | 520fb74cce4c |
comparison
equal
deleted
inserted
replaced
1750:b28f88e352dd | 1751:18ac4d9e5a2a |
---|---|
33 } | 33 } |
34 | 34 |
35 http { | 35 http { |
36 %%TEST_GLOBALS_HTTP%% | 36 %%TEST_GLOBALS_HTTP%% |
37 | 37 |
38 js_set $test_async set_timeout; | 38 js_set $test_async test.set_timeout; |
39 js_set $context_var context_var; | 39 js_set $context_var test.context_var; |
40 js_set $test_set_rv_var set_rv_var; | 40 js_set $test_set_rv_var test.set_rv_var; |
41 | 41 |
42 js_include test.js; | 42 js_import test.js; |
43 | 43 |
44 server { | 44 server { |
45 listen 127.0.0.1:8080; | 45 listen 127.0.0.1:8080; |
46 server_name localhost; | 46 server_name localhost; |
47 | 47 |
48 location /njs { | 48 location /njs { |
49 js_content test_njs; | 49 js_content test.njs; |
50 } | 50 } |
51 | 51 |
52 location /async_var { | 52 location /async_var { |
53 return 200 $test_async; | 53 return 200 $test_async; |
54 } | 54 } |
55 | 55 |
56 location /shared_ctx { | 56 location /shared_ctx { |
57 add_header H $context_var; | 57 add_header H $context_var; |
58 js_content shared_ctx; | 58 js_content test.shared_ctx; |
59 } | 59 } |
60 | 60 |
61 location /set_timeout { | 61 location /set_timeout { |
62 js_content set_timeout; | 62 js_content test.set_timeout; |
63 } | 63 } |
64 | 64 |
65 location /set_timeout_many { | 65 location /set_timeout_many { |
66 js_content set_timeout_many; | 66 js_content test.set_timeout_many; |
67 } | 67 } |
68 | 68 |
69 location /set_timeout_data { | 69 location /set_timeout_data { |
70 postpone_output 0; | 70 postpone_output 0; |
71 js_content set_timeout_data; | 71 js_content test.set_timeout_data; |
72 } | 72 } |
73 | 73 |
74 location /limit_rate { | 74 location /limit_rate { |
75 postpone_output 0; | 75 postpone_output 0; |
76 sendfile_max_chunk 5; | 76 sendfile_max_chunk 5; |
77 js_content limit_rate; | 77 js_content test.limit_rate; |
78 } | 78 } |
79 | 79 |
80 location /async_content { | 80 location /async_content { |
81 js_content async_content; | 81 js_content test.async_content; |
82 } | 82 } |
83 | 83 |
84 location /set_rv_var { | 84 location /set_rv_var { |
85 return 200 $test_set_rv_var; | 85 return 200 $test_set_rv_var; |
86 } | 86 } |
192 const a2 = await pr(20); | 192 const a2 = await pr(20); |
193 | 193 |
194 r.setReturnValue(`retval: \${a1 + a2}`); | 194 r.setReturnValue(`retval: \${a1 + a2}`); |
195 } | 195 } |
196 | 196 |
197 export default {njs:test_njs, set_timeout, set_timeout_data, | |
198 set_timeout_many, context_var, shared_ctx, limit_rate, | |
199 async_content, set_rv_var}; | |
200 | |
197 EOF | 201 EOF |
198 | 202 |
199 $t->try_run('no njs available')->plan(9); | 203 $t->try_run('no njs available')->plan(9); |
200 | 204 |
201 ############################################################################### | 205 ############################################################################### |