kill the debug lines
[catagits/Web-Session.git] / t / middleware.t
CommitLineData
fe1bfe7d 1use Plack::Test;
2use Plack::Middleware::Session;
3use Test::More;
4use HTTP::Request::Common;
5use HTTP::Cookies;
6
7my $app = sub {
8 my $env = shift;
9 my $counter = $env->{'psgix.session'}->get('counter') || 0;
10
11 my $body = "Counter=$counter";
12 $counter++;
13 $env->{'psgix.session'}->set(counter => $counter);
14
15 return [ 200, [], [ $body ] ];
16};
17
18$app = Plack::Middleware::Session->wrap($app);
19
20test_psgi $app, sub {
21 my $cb = shift;
22
23 my $jar = HTTP::Cookies->new;
24
25 my $res = $cb->(GET "http://localhost/");
26 is $res->content, "Counter=0";
27 $jar->extract_cookies($res);
28
29 my $req = GET "http://localhost/";
30 $jar->add_cookie_header($req);
fe1bfe7d 31 $res = $cb->($req);
32 is $res->content, "Counter=1";
33};
34
35done_testing;
36