Skip to content

Commit b44a754

Browse files
committed
Tests: index tests for configuration token starting with variable.
1 parent c388943 commit b44a754

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

index2.t

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/perl
2+
3+
# (C) Sergey Kandaurov
4+
# (C) Nginx, Inc.
5+
6+
# Tests for index module, which is a helper for testing
7+
# configuration token that starts with a variable.
8+
9+
###############################################################################
10+
11+
use warnings;
12+
use strict;
13+
14+
use Test::More;
15+
16+
BEGIN { use FindBin; chdir($FindBin::Bin); }
17+
18+
use lib 'lib';
19+
use Test::Nginx;
20+
21+
###############################################################################
22+
23+
select STDERR; $| = 1;
24+
select STDOUT; $| = 1;
25+
26+
my $t = Test::Nginx->new()->has(qw/http/)
27+
->write_file_expand('nginx.conf', <<'EOF');
28+
29+
%%TEST_GLOBALS%%
30+
31+
daemon off;
32+
33+
events {
34+
}
35+
36+
http {
37+
%%TEST_GLOBALS_HTTP%%
38+
39+
server {
40+
listen 127.0.0.1:8080;
41+
server_name localhost;
42+
add_header X-URI $uri;
43+
44+
location /var/ {
45+
alias %%TESTDIR%%/;
46+
index ${server_name}html;
47+
}
48+
}
49+
}
50+
51+
EOF
52+
53+
$t->write_file('localhosthtml', 'varbody');
54+
55+
$t->try_run('unsupported token')->plan(1);
56+
57+
###############################################################################
58+
59+
like(http_get('/var/'), qr/X-URI: \/var\/localhosthtml.*varbody/ms, 'var');
60+
61+
###############################################################################

0 commit comments

Comments
 (0)