Mercurial > hg > nginx-tests
comparison http_try_files.t @ 189:802fc0786165
Tests: some try_files tests.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Mon, 19 Dec 2011 17:08:18 +0300 |
parents | |
children | 35d050d7d5f1 |
comparison
equal
deleted
inserted
replaced
188:101b092b67e2 | 189:802fc0786165 |
---|---|
1 #!/usr/bin/perl | |
2 | |
3 # (C) Maxim Dounin | |
4 | |
5 # Tests for try_files directive. | |
6 | |
7 ############################################################################### | |
8 | |
9 use warnings; | |
10 use strict; | |
11 | |
12 use Test::More; | |
13 | |
14 BEGIN { use FindBin; chdir($FindBin::Bin); } | |
15 | |
16 use lib 'lib'; | |
17 use Test::Nginx; | |
18 | |
19 ############################################################################### | |
20 | |
21 select STDERR; $| = 1; | |
22 select STDOUT; $| = 1; | |
23 | |
24 my $t = Test::Nginx->new()->has(qw/http rewrite/)->plan(3) | |
25 ->write_file_expand('nginx.conf', <<'EOF'); | |
26 | |
27 %%TEST_GLOBALS%% | |
28 | |
29 daemon off; | |
30 | |
31 events { | |
32 } | |
33 | |
34 http { | |
35 %%TEST_GLOBALS_HTTP%% | |
36 | |
37 server { | |
38 listen 127.0.0.1:8080; | |
39 server_name localhost; | |
40 | |
41 location / { | |
42 try_files $uri /fallback; | |
43 } | |
44 | |
45 location /nouri/ { | |
46 try_files $uri /fallback_nouri; | |
47 } | |
48 | |
49 location /fallback { | |
50 proxy_pass http://127.0.0.1:8081/fallback; | |
51 } | |
52 location /fallback_nouri { | |
53 proxy_pass http://127.0.0.1:8081; | |
54 } | |
55 } | |
56 | |
57 server { | |
58 listen 127.0.0.1:8081; | |
59 server_name localhost; | |
60 | |
61 location / { | |
62 add_header X-URI $request_uri; | |
63 return 204; | |
64 } | |
65 } | |
66 } | |
67 | |
68 EOF | |
69 | |
70 $t->write_file('found.html', 'SEE THIS'); | |
71 $t->run(); | |
72 | |
73 ############################################################################### | |
74 | |
75 like(http_get('/found.html'), qr!SEE THIS!, 'found'); | |
76 like(http_get('/uri/notfound'), qr!X-URI: /fallback!, 'not found uri'); | |
77 | |
78 TODO: { | |
79 local $TODO = 'fixed in 1.1.12'; | |
80 | |
81 like(http_get('/nouri/notfound'), qr!X-URI: /fallback!, 'not found nouri'); | |
82 | |
83 } | |
84 | |
85 ############################################################################### |