comparison proxy_cache_revalidate.t @ 467:43e05ac6c23c

Tests: the read_file function added in Test::Nginx.
author Sergey Kandaurov <pluknet@nginx.com>
date Mon, 22 Sep 2014 13:30:04 +0400
parents f620d9529ed6
children 9a6e0ede4b92
comparison
equal deleted inserted replaced
466:a64b4057189c 467:43e05ac6c23c
100 100
101 like(http_get('/t'), qr/X-Cache-Status: REVALIDATED.*SEE/ms, 'revalidated'); 101 like(http_get('/t'), qr/X-Cache-Status: REVALIDATED.*SEE/ms, 'revalidated');
102 like(http_get('/t'), qr/X-Cache-Status: HIT.*SEE/ms, 'cached again'); 102 like(http_get('/t'), qr/X-Cache-Status: HIT.*SEE/ms, 'cached again');
103 103
104 select undef, undef, undef, 0.1; 104 select undef, undef, undef, 0.1;
105 like(read_file($t->testdir() . '/access.log'), qr/ 304 /, 'not modified'); 105 like($t->read_file('access.log'), qr/ 304 /, 'not modified');
106 106
107 # 2nd document is recreated with a new content 107 # 2nd document is recreated with a new content
108 108
109 $t->write_file('t2', 'NEW'); 109 $t->write_file('t2', 'NEW');
110 like(http_get('/t2'), qr/X-Cache-Status: EXPIRED.*NEW/ms, 'revalidate failed'); 110 like(http_get('/t2'), qr/X-Cache-Status: EXPIRED.*NEW/ms, 'revalidate failed');
128 'etag2 revalidate failed'); 128 'etag2 revalidate failed');
129 like(http_get('/etag/t2'), qr/X-Cache-Status: HIT.*NEW/ms, 129 like(http_get('/etag/t2'), qr/X-Cache-Status: HIT.*NEW/ms,
130 'etag2 new response cached'); 130 'etag2 new response cached');
131 131
132 ############################################################################### 132 ###############################################################################
133
134 sub read_file {
135 my ($file) = @_;
136 my $log;
137
138 local $/;
139
140 open LOG, $file or die "Can't open $file: $!\n";
141 $log = <LOG>;
142 close LOG;
143
144 return $log;
145 }
146
147 ###############################################################################