diff options
| author | franck cuny <franck@lumberjaph.net> | 2011-01-21 11:18:15 +0100 |
|---|---|---|
| committer | franck cuny <franck@lumberjaph.net> | 2011-01-21 11:18:15 +0100 |
| commit | 85173eb97566c5531f047098d0b0b6209b51c25d (patch) | |
| tree | 1eb1158c2906a80005eb1e5f8d39e0d6338e77b7 /t | |
| parent | Checking in changes prior to tagging of version 0.01. Changelog diff is: (diff) | |
| download | plack-middleware-etag-85173eb97566c5531f047098d0b0b6209b51c25d.tar.gz | |
add cache-control and tests
Diffstat (limited to 't')
| -rw-r--r-- | t/01_basic.t | 38 |
1 files changed, 38 insertions, 0 deletions
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; |
