Mercurial > hg > nginx-tests
comparison js_return.t @ 1320:8bd4b88fcac5
Tests: TODO js_return.t fail seen with older njs on some platforms.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Fri, 06 Apr 2018 17:21:23 +0300 |
parents | a05f377bf0ca |
children | f168fc46c7a4 |
comparison
equal
deleted
inserted
replaced
1319:3b30e97acdcb | 1320:8bd4b88fcac5 |
---|---|
9 | 9 |
10 use warnings; | 10 use warnings; |
11 use strict; | 11 use strict; |
12 | 12 |
13 use Test::More; | 13 use Test::More; |
14 | |
15 use Config; | |
14 | 16 |
15 BEGIN { use FindBin; chdir($FindBin::Bin); } | 17 BEGIN { use FindBin; chdir($FindBin::Bin); } |
16 | 18 |
17 use lib 'lib'; | 19 use lib 'lib'; |
18 use Test::Nginx; | 20 use Test::Nginx; |
39 | 41 |
40 server { | 42 server { |
41 listen 127.0.0.1:8080; | 43 listen 127.0.0.1:8080; |
42 server_name localhost; | 44 server_name localhost; |
43 | 45 |
46 location /njs { | |
47 js_content test_njs; | |
48 } | |
49 | |
44 location / { | 50 location / { |
45 js_content test_return; | 51 js_content test_return; |
46 } | 52 } |
47 } | 53 } |
48 } | 54 } |
49 | 55 |
50 EOF | 56 EOF |
51 | 57 |
52 $t->write_file('test.js', <<EOF); | 58 $t->write_file('test.js', <<EOF); |
59 function test_njs(req, res) { | |
60 res.return(200, njs.version); | |
61 } | |
62 | |
53 function test_return(req, res) { | 63 function test_return(req, res) { |
54 njs.version; | |
55 res.return(Number(req.args.c), req.args.t); | 64 res.return(Number(req.args.c), req.args.t); |
56 } | 65 } |
57 | 66 |
58 EOF | 67 EOF |
59 | 68 |
63 | 72 |
64 like(http_get('/?c=200'), qr/200 OK.*\x0d\x0a?\x0d\x0a?$/s, 'return code'); | 73 like(http_get('/?c=200'), qr/200 OK.*\x0d\x0a?\x0d\x0a?$/s, 'return code'); |
65 like(http_get('/?c=200&t=SEE-THIS'), qr/200 OK.*^SEE-THIS$/ms, 'return text'); | 74 like(http_get('/?c=200&t=SEE-THIS'), qr/200 OK.*^SEE-THIS$/ms, 'return text'); |
66 like(http_get('/?c=301&t=path'), qr/ 301 .*Location: path/s, 'return redirect'); | 75 like(http_get('/?c=301&t=path'), qr/ 301 .*Location: path/s, 'return redirect'); |
67 like(http_get('/?c=404'), qr/404 Not.*html/s, 'return error page'); | 76 like(http_get('/?c=404'), qr/404 Not.*html/s, 'return error page'); |
77 | |
78 TODO: { | |
79 my ($v) = http_get('/njs') =~ /^([.0-9]+)$/m; | |
80 local $TODO = 'not yet' unless $v ge '0.2.1' or $Config{archname} !~ /aarch64/; | |
81 | |
68 like(http_get('/?c=inv'), qr/ 500 /, 'return invalid'); | 82 like(http_get('/?c=inv'), qr/ 500 /, 'return invalid'); |
69 | 83 |
84 } | |
85 | |
70 ############################################################################### | 86 ############################################################################### |