From 85173eb97566c5531f047098d0b0b6209b51c25d Mon Sep 17 00:00:00 2001 From: franck cuny Date: Fri, 21 Jan 2011 11:18:15 +0100 Subject: add cache-control and tests --- t/01_basic.t | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 't') diff --git a/t/01_basic.t b/t/01_basic.t index 60cdb66..368d5cc 100644 --- a/t/01_basic.t +++ b/t/01_basic.t @@ -38,6 +38,17 @@ my $file_handler = builder { sub {[200, ['Content-Type' => 'text/html', ], $fh]}; }; +my $cache_control = builder { + enable "Plack::Middleware::ETag", cache_control => 1; + sub { [ '200', [ 'Content-Type' => 'text/html' ], $content ] }; +}; + +my $cache_control_array = builder { + enable "Plack::Middleware::ETag", + cache_control => [ 'must-revalidate', 'max-age=3600', 'no-store' ]; + sub { [ '200', [ 'Content-Type' => 'text/html' ], $content ] }; +}; + test_psgi app => $handler, client => sub { @@ -88,4 +99,31 @@ test_psgi } }; +test_psgi + app => $cache_control, + client => sub { + my $cb = shift; + { + my $req = GET "http://localhost/"; + my $res = $cb->($req); + ok $res->header('ETag'); + is $res->header('ETag'), $sha; + is $res->header('Cache-Control'), 'must-revalidate'; + } + }; + +test_psgi + app => $cache_control_array, + client => sub { + my $cb = shift; + { + my $req = GET "http://localhost/"; + my $res = $cb->($req); + ok $res->header('ETag'); + is $res->header('ETag'), $sha; + is $res->header('Cache-Control'), + 'must-revalidate, max-age=3600, no-store'; + } + }; + done_testing; -- cgit v1.2.3