Mercurial > hg > nginx-tests
comparison stream_js.t @ 1248:70192b1baf01
Tests: added exception test to stream_js.t using 'require'.
The stream js tests introduced in edf5a3c9e36a fail on njs 0.1.14. It doesn't
currently provide an easy way to check its version, whilst we are obligated to
gracefully handle such cases somehow. With such an addition of 'require', now
the tests are skipped instead on the previous versions.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Tue, 21 Nov 2017 13:16:39 +0300 |
parents | edf5a3c9e36a |
children | 3882f8f3b2bc |
comparison
equal
deleted
inserted
replaced
1247:edf5a3c9e36a | 1248:70192b1baf01 |
---|---|
105 } | 105 } |
106 | 106 |
107 server { | 107 server { |
108 listen 127.0.0.1:8092; | 108 listen 127.0.0.1:8092; |
109 js_filter js_filter_except; | 109 js_filter js_filter_except; |
110 proxy_pass 127.0.0.1:8090; | |
111 } | |
112 | |
113 server { | |
114 listen 127.0.0.1:8093; | |
115 js_preread js_preread_except; | |
110 proxy_pass 127.0.0.1:8090; | 116 proxy_pass 127.0.0.1:8090; |
111 } | 117 } |
112 } | 118 } |
113 | 119 |
114 EOF | 120 EOF |
179 return; | 185 return; |
180 } | 186 } |
181 res += '3'; | 187 res += '3'; |
182 } | 188 } |
183 | 189 |
190 function js_preread_except(sess) { | |
191 var fs = require('fs'); | |
192 fs.readFileSync(); | |
193 } | |
194 | |
184 function js_filter_except(sess) { | 195 function js_filter_except(sess) { |
185 sess.a.a; | 196 sess.a.a; |
186 } | 197 } |
187 | 198 |
188 EOF | 199 EOF |
189 | 200 |
190 $t->run_daemon(\&stream_daemon, port(8090)); | 201 $t->run_daemon(\&stream_daemon, port(8090)); |
191 $t->try_run('no stream njs available')->plan(13); | 202 $t->try_run('no stream njs available')->plan(14); |
192 $t->waitforsocket('127.0.0.1:' . port(8090)); | 203 $t->waitforsocket('127.0.0.1:' . port(8090)); |
193 | 204 |
194 ############################################################################### | 205 ############################################################################### |
195 | 206 |
196 is(stream('127.0.0.1:' . port(8080))->read(), 'addr=127.0.0.1', | 207 is(stream('127.0.0.1:' . port(8080))->read(), 'addr=127.0.0.1', |
206 is(stream('127.0.0.1:' . port(8087))->read(), '', 'js_access deny'); | 217 is(stream('127.0.0.1:' . port(8087))->read(), '', 'js_access deny'); |
207 is(stream('127.0.0.1:' . port(8088))->io('xyz'), 'xyz', 'js_preread'); | 218 is(stream('127.0.0.1:' . port(8088))->io('xyz'), 'xyz', 'js_preread'); |
208 is(stream('127.0.0.1:' . port(8089))->io('x'), 'z', 'js_filter'); | 219 is(stream('127.0.0.1:' . port(8089))->io('x'), 'z', 'js_filter'); |
209 is(stream('127.0.0.1:' . port(8091))->io('0'), '01233', 'handlers order'); | 220 is(stream('127.0.0.1:' . port(8091))->io('0'), '01233', 'handlers order'); |
210 stream('127.0.0.1:' . port(8092))->io('x'); | 221 stream('127.0.0.1:' . port(8092))->io('x'); |
222 stream('127.0.0.1:' . port(8093))->io('x'); | |
211 | 223 |
212 $t->stop(); | 224 $t->stop(); |
213 | 225 |
214 ok(index($t->read_file('error.log'), 'SEE-THIS') > 0, 'stream js log'); | 226 ok(index($t->read_file('error.log'), 'SEE-THIS') > 0, 'stream js log'); |
227 ok(index($t->read_file('error.log'), 'at fs.readFileSync') > 0, | |
228 'stream js_preread backtrace'); | |
215 ok(index($t->read_file('error.log'), 'at js_filter_except') > 0, | 229 ok(index($t->read_file('error.log'), 'at js_filter_except') > 0, |
216 'stream js_filter backtrace'); | 230 'stream js_filter backtrace'); |
217 | 231 |
218 ############################################################################### | 232 ############################################################################### |
219 | 233 |