Tests: various index module error cases.
diff --git a/index.t b/index.t
index bc8263f..43717bc 100644
--- a/index.t
+++ b/index.t
@@ -22,7 +22,7 @@
select STDERR; $| = 1;
select STDOUT; $| = 1;
-my $t = Test::Nginx->new()->has(qw/http/)->plan(8)
+my $t = Test::Nginx->new()->has(qw/http/)->plan(14)
->write_file_expand('nginx.conf', <<'EOF');
%%TEST_GLOBALS%%
@@ -77,6 +77,15 @@
location /var_redirect/ {
index /$server_name.html;
}
+
+ location /not_found/ {
+ error_log %%TESTDIR%%/log_not_found.log;
+
+ location /not_found/off/ {
+ error_log %%TESTDIR%%/off.log;
+ log_not_found off;
+ }
+ }
}
}
@@ -87,6 +96,10 @@
$t->write_file('re.html', 'rebody');
$t->write_file('localhost.html', 'varbody');
+my $d = $t->testdir();
+mkdir("$d/forbidden");
+chmod(0000, "$d/forbidden");
+
$t->run();
###############################################################################
@@ -101,4 +114,14 @@
like(http_get('/var_redirect/'), qr/X-URI: \/localhost.html.*varbody/ms,
'var with redirect');
+like(http_get('/not_found/'), qr/404 Not Found/, 'not found');
+like(http_get('/not_found/off/'), qr/404 Not Found/, 'not found log off');
+like(http_get('/forbidden/'), qr/403 Forbidden/, 'directory access denied');
+like(http_get('/index.html/'), qr/404 Not Found/, 'not a directory');
+
+$t->stop();
+
+like($t->read_file('log_not_found.log'), qr/error/, 'log_not_found');
+unlike($t->read_file('off.log'), qr/error/, 'log_not_found off');
+
###############################################################################