summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2010-02-28 12:38:51 +0100
committerfranck cuny <franck@lumberjaph.net>2010-02-28 12:38:51 +0100
commitd304286cf4ed607474312e0fb831b2406a610501 (patch)
treec133154eef9bf570a441d60ae800329413f622c0 /t
parentupdate readme and makefile (diff)
downloadplack-middleware-etag-d304286cf4ed607474312e0fb831b2406a610501.tar.gz
test with conditionalGET, update POD
Diffstat (limited to 't')
-rw-r--r--t/01_basic.t23
1 files changed, 21 insertions, 2 deletions
diff --git a/t/01_basic.t b/t/01_basic.t
index 0bc49c6..8564ece 100644
--- a/t/01_basic.t
+++ b/t/01_basic.t
@@ -9,6 +9,7 @@ use Plack::Builder;
use HTTP::Request::Common;
my $content = [qw/hello world/];
+my $sha = Digest::SHA->new->add(@$content)->hexdigest;
my $handler = builder {
enable "Plack::Middleware::ETag";
@@ -25,6 +26,12 @@ my $second_handler = builder {
};
};
+my $unmodified_handler = builder {
+ enable "Plack::Middleware::ConditionalGET";
+ enable "Plack::Middleware::ETag";
+ sub { [ '200', [ 'Content-Type' => 'text/html' ], $content ] };
+};
+
test_psgi
app => $handler,
client => sub {
@@ -33,8 +40,7 @@ test_psgi
my $req = GET "http://localhost/";
my $res = $cb->($req);
ok $res->header('ETag');
- my $sha = Digest::SHA->new->add(@$content);
- is $res->header('ETag'), $sha->hexdigest;
+ is $res->header('ETag'), $sha;
}
};
@@ -50,4 +56,17 @@ test_psgi
}
};
+test_psgi
+ app => $unmodified_handler,
+ client => sub {
+ my $cb = shift;
+ {
+ my $req = GET "http://localhost/", 'If-None-Match' => $sha;
+ my $res = $cb->($req);
+ ok $res->header('ETag');
+ is $res->code, 304;
+ ok !$res->content;
+ }
+};
+
done_testing;