# HG changeset patch # User Sergey Kandaurov # Date 1539189142 -10800 # Node ID 261f01ee53646894bc43b71178a78dbe18dbc0b6 # Parent 5eb82b417fd66fc17f9958a725b32abf1f8df1c6 Tests: index module tests merged. diff --git a/index.t b/index.t --- a/index.t +++ b/index.t @@ -22,7 +22,7 @@ use Test::Nginx; select STDERR; $| = 1; select STDOUT; $| = 1; -my $t = Test::Nginx->new()->has(qw/http/)->plan(7) +my $t = Test::Nginx->new()->has(qw/http/)->plan(8) ->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%% @@ -67,6 +67,13 @@ http { index $server_name.html; } + location /va2/ { + alias %%TESTDIR%%/; + # before 1.13.8, the token produced emerg: + # directive "index" is not terminated by ";" + index ${server_name}.html; + } + location /var_redirect/ { index /$server_name.html; } @@ -90,6 +97,7 @@ like(http_get('/redirect/'), qr/X-URI: \ like(http_get('/loop/'), qr/500 Internal/, 'redirect loop'); like(http_get('/many/'), qr/X-URI: \/many\/many.html.*manybody/ms, 'many'); like(http_get('/var/'), qr/X-URI: \/var\/localhost.html.*varbody/ms, 'var'); +like(http_get('/va2/'), qr/X-URI: \/va2\/localhost.html.*varbody/ms, 'var 2'); like(http_get('/var_redirect/'), qr/X-URI: \/localhost.html.*varbody/ms, 'var with redirect'); diff --git a/index2.t b/index2.t deleted file mode 100644 --- a/index2.t +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/perl - -# (C) Sergey Kandaurov -# (C) Nginx, Inc. - -# Tests for index module, which is a helper for testing -# configuration token that starts with a variable. - -############################################################################### - -use warnings; -use strict; - -use Test::More; - -BEGIN { use FindBin; chdir($FindBin::Bin); } - -use lib 'lib'; -use Test::Nginx; - -############################################################################### - -select STDERR; $| = 1; -select STDOUT; $| = 1; - -my $t = Test::Nginx->new()->has(qw/http/)->plan(1) - ->write_file_expand('nginx.conf', <<'EOF'); - -%%TEST_GLOBALS%% - -daemon off; - -events { -} - -http { - %%TEST_GLOBALS_HTTP%% - - server { - listen 127.0.0.1:8080; - server_name localhost; - add_header X-URI $uri; - - location /var/ { - alias %%TESTDIR%%/; - index ${server_name}html; - } - } -} - -EOF - -$t->write_file('localhosthtml', 'varbody'); - -$t->run(); - -############################################################################### - -like(http_get('/var/'), qr/X-URI: \/var\/localhosthtml.*varbody/ms, 'var'); - -###############################################################################