Mercurial > hg > nginx-tests
diff 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 |
line wrap: on
line diff
--- a/stream_js.t Mon Nov 20 20:23:24 2017 +0300 +++ b/stream_js.t Tue Nov 21 13:16:39 2017 +0300 @@ -109,6 +109,12 @@ js_filter js_filter_except; proxy_pass 127.0.0.1:8090; } + + server { + listen 127.0.0.1:8093; + js_preread js_preread_except; + proxy_pass 127.0.0.1:8090; + } } EOF @@ -181,6 +187,11 @@ res += '3'; } + function js_preread_except(sess) { + var fs = require('fs'); + fs.readFileSync(); + } + function js_filter_except(sess) { sess.a.a; } @@ -188,7 +199,7 @@ EOF $t->run_daemon(\&stream_daemon, port(8090)); -$t->try_run('no stream njs available')->plan(13); +$t->try_run('no stream njs available')->plan(14); $t->waitforsocket('127.0.0.1:' . port(8090)); ############################################################################### @@ -208,10 +219,13 @@ is(stream('127.0.0.1:' . port(8089))->io('x'), 'z', 'js_filter'); is(stream('127.0.0.1:' . port(8091))->io('0'), '01233', 'handlers order'); stream('127.0.0.1:' . port(8092))->io('x'); +stream('127.0.0.1:' . port(8093))->io('x'); $t->stop(); ok(index($t->read_file('error.log'), 'SEE-THIS') > 0, 'stream js log'); +ok(index($t->read_file('error.log'), 'at fs.readFileSync') > 0, + 'stream js_preread backtrace'); ok(index($t->read_file('error.log'), 'at js_filter_except') > 0, 'stream js_filter backtrace');