Skip to content

Tests: SSI stub #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions ssi_stub.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/usr/bin/perl

# (C) Maxim Dounin

# Tests for nginx ssi module, waited subrequests.

###############################################################################

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 ssi/)->plan(2);

$t->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;
}
}
}

EOF

$t->write_file('test-stub.html', '<!--# block name="stub" -->STUB<!--# endblock -->' .
'x<!--#include virtual="/empty.html" stub="stub" -->x');

$t->write_file('test-concurrent.html', 'x<!--#include virtual="/first.html" -->' .
'<!--# block name="stub" -->STUB<!--# endblock -->' .
'x<!--#include virtual="/empty.html" stub="stub" -->x');
$t->write_file('first.html', 'FIRST');
$t->write_file('empty.html', '');

$t->run();

###############################################################################

like(http_get('/test-stub.html'), qr/^xSTUBx$/m, 'stub');
like(http_get('/test-concurrent.html'), qr/^xFIRSTxSTUBx$/m, 'concurrent');

###############################################################################