Mercurial > hg > nginx-tests
changeset 1386:261f01ee5364
Tests: index module tests merged.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Wed, 10 Oct 2018 19:32:22 +0300 |
parents | 5eb82b417fd6 |
children | ad3cb6f451a5 |
files | index.t index2.t |
diffstat | 2 files changed, 9 insertions(+), 62 deletions(-) [+] |
line wrap: on
line diff
--- a/index.t Wed Oct 10 19:15:49 2018 +0300 +++ b/index.t Wed Oct 10 19:32:22 2018 +0300 @@ -22,7 +22,7 @@ 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 @@ 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('/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');
--- a/index2.t Wed Oct 10 19:15:49 2018 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -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'); - -###############################################################################