Mercurial > hg > nginx-tests
changeset 369:4ac3588485f5
Tests: added tests for embedded ssi variable.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Tue, 28 Jan 2014 16:18:04 +0400 |
parents | fc6b8270469c |
children | 74cfe56c7b83 |
files | ssi.t |
diffstat | 1 files changed, 46 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/ssi.t Mon Jan 20 21:09:58 2014 +0400 +++ b/ssi.t Tue Jan 28 16:18:04 2014 +0400 @@ -23,7 +23,7 @@ plan(skip_all => 'win32') if $^O eq 'MSWin32'; -my $t = Test::Nginx->new()->has(qw/http ssi cache proxy rewrite/)->plan(21); +my $t = Test::Nginx->new()->has(qw/http ssi cache proxy rewrite/)->plan(27); $t->write_file_expand('nginx.conf', <<'EOF'); @@ -64,6 +64,19 @@ ssi off; alias %%TESTDIR%%/; } + location /var { + ssi on; + add_header X-Var $date_gmt; + } + location /var_noformat { + ssi on; + add_header X-Var $date_gmt; + return 200; + } + location /var_nossi { + add_header X-Var $date_gmt; + return 200; + } } } @@ -91,6 +104,16 @@ $t->write_file('unescape3.html', 'X<!--#include virtual="/test1.html%3ftest=test" -->X'); +$t->write_file('var_format.html', + 'x<!--#if expr="$arg_custom" -->' + . '<!--#config timefmt="%A, %H:%M:%S" -->' + . '<!--#set var="v" value="$date_gmt" -->' + . '<!--#echo var="v" -->' + . '<!--#else -->' + . '<!--#set var="v" value="$date_gmt" -->' + . '<!--#echo var="v" -->' + . '<!--#endif -->x'); + $t->run(); ############################################################################### @@ -142,6 +165,28 @@ } +# handling of embedded date variables + +TODO: { +local $TODO = 'not yet' unless $t->has_version('1.5.10'); + +like(http_get('/var_nossi.html'), + qr/X-Var: \w+, \d\d-\w{3}-\d{4} \d\d:\d\d:\d\d \w+/, 'no ssi'); +like(http_get('/var_noformat.html'), + qr/X-Var: \w+, \d\d-\w{3}-\d{4} \d\d:\d\d:\d\d \w+/, 'no format'); + +like(http_get('/var_format.html?custom=1'), + qr/X-Var: \w+, \d\d-\w{3}-\d{4} \d\d:\d\d:\d\d \w+/, 'custom header'); +like(http_get('/var_format.html'), + qr/X-Var: \w+, \d\d-\w{3}-\d{4} \d\d:\d\d:\d\d \w+/, 'default header'); + +} + +like(http_get('/var_format.html?custom=1'), + qr/x\w+, \d\d:\d\d:\d\dx/, 'custom ssi'); +like(http_get('/var_format.html'), + qr/x\w+, \d\d-\w{3}-\d{4} \d\d:\d\d:\d\d \w+x/, 'default ssi'); + like(`grep -F '[alert]' ${\($t->testdir())}/error.log`, qr/^$/s, 'no alerts'); ###############################################################################