[PATCH] Tests: index test for flushing non-cacheable variables
Maxim Dounin
mdounin at mdounin.ru
Sun Jul 12 22:15:22 UTC 2026
# HG changeset patch
# User Maxim Dounin <mdounin at mdounin.ru>
# Date 1783893091 -10800
# Mon Jul 13 00:51:31 2026 +0300
# Node ID 974aab326913908b055756608c21cae482c4b2ad
# Parent dc84b1a21af6e705131a28dfd2709e29cfc2ccb4
Tests: index test for flushing non-cacheable variables.
diff --git a/index.t b/index.t
--- a/index.t
+++ b/index.t
@@ -1,5 +1,6 @@
#!/usr/bin/perl
+# (C) Maxim Dounin
# (C) Sergey Kandaurov
# (C) Nginx, Inc.
@@ -22,7 +23,7 @@ use Test::Nginx;
select STDERR; $| = 1;
select STDOUT; $| = 1;
-my $t = Test::Nginx->new()->has(qw/http rewrite map/)->plan(16)
+my $t = Test::Nginx->new()->has(qw/http rewrite map/)->plan(17)
->write_file_expand('nginx.conf', <<'EOF');
%%TEST_GLOBALS%%
@@ -43,6 +44,11 @@ http {
~(?<shrink>) "";
}
+ map $index $map_volatile {
+ volatile;
+ ~^ $index;
+ }
+
server {
listen 127.0.0.1:8080;
server_name localhost;
@@ -99,11 +105,20 @@ http {
alias %%TESTDIR%%/;
index index.$capture.$map_capture /index.html;
}
+
location /shrink/ {
alias %%TESTDIR%%/;
set $shrink "some-long-variable-value";
index index$shrink$map_shrink.html /index.html;
}
+
+ location /volatile/ {
+ alias %%TESTDIR%%/;
+ set $index notfound.html;
+ set $dummy $map_volatile;
+ set $index index.html;
+ index $map_volatile;
+ }
}
}
@@ -156,6 +171,14 @@ like(http_get('/shrink/'), qr!X-URI: /sh
}
+TODO: {
+local $TODO = 'not yet' unless $t->has_version('1.31.4');
+
+like(http_get('/volatile/'), qr!X-URI: /volatile/index.html\x0d?($).*body!ms,
+ 'index flushes non-cacheable variables');
+
+}
+
$t->stop();
like($t->read_file('log_not_found.log'), qr/error/, 'log_not_found');
More information about the nginx-devel
mailing list