Mercurial > hg > nginx-tests
view ssi.t @ 107:1c0ec30614c6
Tests: add TEST_GLOBALS and TEST_GLOBALS_HTTP config chunks.
TEST_GLOBALS replaces previously used -g switch. This allows tests
to be executed on 0.6.* branch. For compatibility with old tests -g switch
will be used if TEST_GLOBALS wasn't expaneded in config.
TEST_GLOBALS_HTTP replaces multiple variables (access_log, root,
client_body_temp_path, proxy_temp_path, fastcgi_temp_path) previously
specified directly in test configs. This change reduce duplication and
allows tests to be used with nginx compiled without fastcgi and/or proxy
modules (as proxy_temp_path and fastcgi_temp_path are added conditionally).
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Wed, 14 Oct 2009 02:23:52 +0400 |
parents | 7a712d3909ba |
children | 8ac1faaddd2c |
line wrap: on
line source
#!/usr/bin/perl # (C) Maxim Dounin # Tests for nginx ssi module. ############################################################################### 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('cache')->plan(16); $t->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%% master_process off; daemon off; events { } http { %%TEST_GLOBALS_HTTP%% proxy_cache_path %%TESTDIR%%/cache levels=1:2 keys_zone=NAME:10m; server { listen 127.0.0.1:8080; server_name localhost; location / { ssi on; } location /proxy/ { ssi on; proxy_pass http://127.0.0.1:8080/local/; } location /cache/ { proxy_pass http://127.0.0.1:8080/local/; proxy_cache NAME; proxy_cache_valid 200 1h; } location /local/ { ssi off; alias %%TESTDIR%%/; } } } EOF $t->write_file('test1.html', 'X<!--#echo var="arg_test" -->X'); $t->write_file('test2.html', 'X<!--#include virtual="/test1.html?test=test" -->X'); $t->write_file('test3.html', 'X<!--#set var="blah" value="test" --><!--#echo var="blah" -->X'); $t->write_file('test-empty1.html', 'X<!--#include virtual="/empty.html" -->X'); $t->write_file('test-empty2.html', 'X<!--#include virtual="/local/empty.html" -->X'); $t->write_file('test-empty3.html', 'X<!--#include virtual="/cache/empty.html" -->X'); $t->write_file('empty.html', ''); $t->run(); ############################################################################### like(http_get('/test1.html'), qr/^X\(none\)X$/m, 'echo no argument'); like(http_get('/test1.html?test='), qr/^XX$/m, 'empty argument'); like(http_get('/test1.html?test=test'), qr/^XtestX$/m, 'argument'); like(http_get('/test1.html?test=test&a=b'), qr/^XtestX$/m, 'argument 2'); like(http_get('/test1.html?a=b&test=test'), qr/^XtestX$/m, 'argument 3'); like(http_get('/test1.html?a=b&test=test&d=c'), qr/^XtestX$/m, 'argument 4'); like(http_get('/test1.html?atest=a&testb=b&ctestc=c&test=test'), qr/^XtestX$/m, 'argument 5'); like(http_get('/test2.html'), qr/^XXtestXX$/m, 'argument via include'); like(http_get('/test3.html'), qr/^XtestX$/m, 'set'); # Last-Modified and Accept-Ranges headers should be cleared unlike(http_get('/test1.html'), qr/Last-Modified|Accept-Ranges/im, 'cleared headers'); unlike(http_get('/proxy/test1.html'), qr/Last-Modified|Accept-Ranges/im, 'cleared headers from proxy'); like(http_get('/test-empty1.html'), qr/HTTP/, 'empty with ssi'); like(http_get('/test-empty2.html'), qr/HTTP/, 'empty without ssi'); like(http_get('/test-empty3.html'), qr/HTTP/, 'empty with proxy'); like(http_get('/test-empty3.html'), qr/HTTP/, 'empty with proxy cached'); like(`grep -F '[alert]' ${\($t->testdir())}/error.log`, qr/^$/s, 'no alerts'); ###############################################################################