Mercurial > hg > nginx-tests
annotate index2.t @ 1293:4442767118e0
Tests: wrap long line.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Thu, 01 Mar 2018 15:14:43 +0300 |
parents | 200d9d091da2 |
children | 97c8280de681 |
rev | line source |
---|---|
347
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
2 |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
3 # (C) Sergey Kandaurov |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
5 |
1265
200d9d091da2
Tests: index tests for configuration token starting with variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
6 # Tests for index module, which is a helper for testing |
200d9d091da2
Tests: index tests for configuration token starting with variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
7 # configuration token that starts with a variable. |
347
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
8 |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
9 ############################################################################### |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 use warnings; |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 use strict; |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 use Test::More; |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
15 |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
16 BEGIN { use FindBin; chdir($FindBin::Bin); } |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 use lib 'lib'; |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 use Test::Nginx; |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 ############################################################################### |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
22 |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 select STDERR; $| = 1; |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 select STDOUT; $| = 1; |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
25 |
1265
200d9d091da2
Tests: index tests for configuration token starting with variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
26 my $t = Test::Nginx->new()->has(qw/http/) |
347
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
27 ->write_file_expand('nginx.conf', <<'EOF'); |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 %%TEST_GLOBALS%% |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 daemon off; |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 events { |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 } |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 http { |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 %%TEST_GLOBALS_HTTP%% |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
39 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
40 listen 127.0.0.1:8080; |
347
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
41 server_name localhost; |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
42 add_header X-URI $uri; |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
43 |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
44 location /var/ { |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
45 alias %%TESTDIR%%/; |
1265
200d9d091da2
Tests: index tests for configuration token starting with variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
46 index ${server_name}html; |
347
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 } |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
48 } |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 } |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
51 EOF |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 |
1265
200d9d091da2
Tests: index tests for configuration token starting with variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
53 $t->write_file('localhosthtml', 'varbody'); |
347
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
54 |
1265
200d9d091da2
Tests: index tests for configuration token starting with variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
55 $t->try_run('unsupported token')->plan(1); |
347
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
56 |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
57 ############################################################################### |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
58 |
1265
200d9d091da2
Tests: index tests for configuration token starting with variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
59 like(http_get('/var/'), qr/X-URI: \/var\/localhosthtml.*varbody/ms, 'var'); |
347
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
60 |
f6d195aa0303
Tests: added tests for index module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 ############################################################################### |