From b036a6823527fa6f781ef015783bc749fbfb68d2 Mon Sep 17 00:00:00 2001 From: franck cuny Date: Sun, 28 Feb 2010 11:13:58 +0100 Subject: basic tests --- t/01_basic.t | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 t/01_basic.t diff --git a/t/01_basic.t b/t/01_basic.t new file mode 100644 index 0000000..0bc49c6 --- /dev/null +++ b/t/01_basic.t @@ -0,0 +1,53 @@ +use strict; +use warnings; +use Test::More; + +use Digest::SHA; + +use Plack::Test; +use Plack::Builder; +use HTTP::Request::Common; + +my $content = [qw/hello world/]; + +my $handler = builder { + enable "Plack::Middleware::ETag"; + sub { [ '200', [ 'Content-Type' => 'text/html' ], $content ] }; +}; + +my $second_handler = builder { + enable "Plack::Middleware::ETag"; + sub { + [ + '200', [ 'Content-Type' => 'text/html', 'ETag' => '123' ], + $content + ]; + }; +}; + +test_psgi + app => $handler, + client => sub { + my $cb = shift; + { + 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; + } +}; + +test_psgi + app => $second_handler, + client => sub { + my $cb = shift; + { + my $req = GET "http://localhost/"; + my $res = $cb->($req); + ok $res->header('ETag'); + is $res->header('ETag'), '123'; + } +}; + +done_testing; -- cgit v1.2.3