Skip to content

Commit

Permalink
implement
Browse files Browse the repository at this point in the history
  • Loading branch information
cho45 committed Jul 14, 2011
1 parent 0fa4207 commit 4d7374e
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions t/01_base.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
use strict;
use warnings;

use Guard;
use Test::More;
use Plack::Test;
use HTTP::Request::Common;
use File::Temp qw/ :mktemp /;
use POSIX::RT::SharedMem qw(shared_unlink);

use Plack::Middleware::AccessCount;
my $path = mktemp('/access_counterXXXXXX');

my $m = Plack::Middleware::AccessCount->new({
counter_path => $path
});

$m->wrap(sub {
my $env = shift;

[200, [ 'Content-Type' => 'text/plain' ], [ $env->{'psgix.access_counter'} . '' ] ]
});

test_psgi $m => sub { my $server = shift;
is $server->(GET '/')->content, "1";
is $server->(GET '/')->content, "2";
is $server->(GET '/')->content, "3";

{
my $pid;
unless ($pid = fork) {
is $server->(GET '/')->content, "4";
exit;
}
wait;
};

is $server->(GET '/')->content, "5";

{
my $pid;
unless ($pid = fork) {
is $server->(GET '/')->content, "6";
exit;
}
wait;
}

is $server->(GET '/')->content, "7";
};

shared_unlink $path;
done_testing;

0 comments on commit 4d7374e

Please sign in to comment.