changeset 1346:4d5d1e59f45e

Tests: TODO js_internal_redirect.t on njs < 0.2.2. On older njs versions, js runtime exception is thrown: "TypeError: cannot find property 'internalRedirect' of an external object".
author Sergey Kandaurov <pluknet@nginx.com>
date Thu, 14 Jun 2018 10:47:51 +0300
parents 9fbe84b7ddc6
children 106d9f806288
files js_internal_redirect.t
diffstat 1 files changed, 15 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/js_internal_redirect.t
+++ b/js_internal_redirect.t
@@ -43,6 +43,10 @@ http {
         listen       127.0.0.1:8080;
         server_name  localhost;
 
+        location /njs {
+            js_content test_njs;
+        }
+
         location /test {
             js_content test_redirect;
         }
@@ -61,6 +65,10 @@ http {
 EOF
 
 $t->write_file('test.js', <<EOF);
+    function test_njs(r) {
+        r.return(200, njs.version);
+    }
+
     function test_redirect(req) {
         if (req.variables.arg_dest.startsWith('named')) {
             req.internalRedirect('\@named');
@@ -77,12 +85,18 @@ EOF
 
 EOF
 
-$t->try_run('no njs internalRedirect')->plan(3);
+$t->try_run('no njs available')->plan(3);
 
 ###############################################################################
 
+TODO: {
+local $TODO = 'no njs internalRedirect'
+		unless http_get('/njs') =~ /^([.0-9]+)$/m && $1 ge '0.2.2';
+
 like(http_get('/test'), qr/redirect/s, 'redirect');
 like(http_get('/test?a=A'), qr/redirectA/s, 'redirect with args');
 like(http_get('/test?dest=named'), qr/named/s, 'redirect to named location');
 
+}
+
 ###############################################################################