# HG changeset patch # User Maxim Dounin # Date 1720104175 -10800 # Node ID 85d88cd5091c6691d58de81dec544c901f33b6d7 # Parent bf027a972ccf8d6ff141f85e9a41615009e8005b Tests: SSI include stub tests. diff -r bf027a972ccf -r 85d88cd5091c ssi_stub.t --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ssi_stub.t Thu Jul 04 17:42:55 2024 +0300 @@ -0,0 +1,108 @@ +#!/usr/bin/perl + +# (C) Maxim Dounin + +# Tests for nginx ssi module, stub output. + +############################################################################### + +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 proxy ssi/)->plan(4) + ->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; + + location / { + ssi on; + } + + location = /empty { + # static + } + + location = /error404 { + # static 404 + } + + location = /proxy404 { + proxy_pass http://127.0.0.1:8081; + proxy_intercept_errors on; + error_page 404 /error404; + } + + location = /not_empty { + proxy_pass http://127.0.0.1:8081; + } + } + + server { + listen 127.0.0.1:8081; + server_name localhost; + } +} + +EOF + +$t->write_file('empty.html', + 'fallback' . + '::'); + +$t->write_file('error.html', + 'fallback' . + '::'); + +$t->write_file('proxy_error.html', + 'fallback' . + '::'); + +$t->write_file('postponed.html', + 'fallback' . + ':' . + '::'); + +$t->write_file('empty', ''); +$t->write_file('not_empty', 'not empty'); + +$t->run(); + +############################################################################### + +like(http_get('/empty.html'), qr/:fallback:/, 'ssi stub empty'); +like(http_get('/error.html'), qr/:fallback:/, 'ssi stub error'); +like(http_get('/proxy_error.html'), qr/:fallback:/, 'ssi stub proxied error'); + +TODO: { +local $TODO = 'not yet' unless $t->has_version('1.27.2'); + +like(http_get('/postponed.html'), qr/:not empty:fallback:/s, + 'ssi stub postponed'); + +} + +###############################################################################