Mercurial > hg > nginx-tests
comparison stream_js_variables.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 | bc0990ea2e5b |
children |
comparison
equal
deleted
inserted
replaced
1750:b28f88e352dd | 1751:18ac4d9e5a2a |
---|---|
34 } | 34 } |
35 | 35 |
36 stream { | 36 stream { |
37 %%TEST_GLOBALS_STREAM%% | 37 %%TEST_GLOBALS_STREAM%% |
38 | 38 |
39 js_set $test_var test_var; | 39 js_set $test_var test.variable; |
40 js_set $test_not_found test_not_found; | 40 js_set $test_not_found test.not_found; |
41 | 41 |
42 js_include test.js; | 42 js_import test.js; |
43 | 43 |
44 server { | 44 server { |
45 listen 127.0.0.1:8081; | 45 listen 127.0.0.1:8081; |
46 return $test_var$status; | 46 return $test_var$status; |
47 } | 47 } |
53 } | 53 } |
54 | 54 |
55 EOF | 55 EOF |
56 | 56 |
57 $t->write_file('test.js', <<EOF); | 57 $t->write_file('test.js', <<EOF); |
58 function test_var(s) { | 58 function variable(s) { |
59 s.variables.status = 400; | 59 s.variables.status = 400; |
60 return 'test_var'; | 60 return 'test_var'; |
61 } | 61 } |
62 | 62 |
63 function test_not_found(s) { | 63 function not_found(s) { |
64 try { | 64 try { |
65 s.variables.unknown = 1; | 65 s.variables.unknown = 1; |
66 } catch (e) { | 66 } catch (e) { |
67 return 'not_found'; | 67 return 'not_found'; |
68 } | 68 } |
69 } | 69 } |
70 | |
71 export default {variable, not_found}; | |
70 | 72 |
71 EOF | 73 EOF |
72 | 74 |
73 $t->try_run('no stream njs available')->plan(2); | 75 $t->try_run('no stream njs available')->plan(2); |
74 | 76 |