Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 57 lines (48 sloc) 1.237 kb
8496033a »
2010-09-06 Basic PSGI handler.
1 #!perl
2 use warnings;
3 use strict;
4c086a57 »
2010-12-19 Increase test hardness when RELEASE_TESTING
4 use constant CLIENTS => $ENV{RELEASE_TESTING} ? 15 : 2;
27f9207d »
2010-09-16 Get rid of AnyEvent::HTTP dep, clean up tests.
5 use Test::More tests => 4 + 5*CLIENTS;
8496033a »
2010-09-06 Basic PSGI handler.
6 use lib 't'; use Utils;
7
8 BEGIN { use_ok('Feersum') };
9
10 my ($socket,$port) = get_listen_socket();
11 ok $socket, "made listen socket";
12
13 my $evh = Feersum->new();
14 {
15 no warnings 'redefine';
16 *Feersum::DIED = sub {
17 my $err = shift;
18 fail "Died during request handler: $err";
19 };
20 }
21 $evh->use_socket($socket);
22
23 my $APP = <<'EOAPP';
24 my $app = sub {
25 my $env = shift;
26 Test::More::ok $env, "got an env in callback";
27 return [
28 200,
29 ['Content-Type' => 'text/plain'],
27f9207d »
2010-09-16 Get rid of AnyEvent::HTTP dep, clean up tests.
30 ['Hello ','World']
8496033a »
2010-09-06 Basic PSGI handler.
31 ];
32 };
33 EOAPP
34
35 my $app = eval $APP;
36 ok $app, 'got an app' || diag $@;
37 $evh->psgi_request_handler($app);
38
39 my $cv = AE::cv;
40
27f9207d »
2010-09-16 Get rid of AnyEvent::HTTP dep, clean up tests.
41 for my $n (1 .. CLIENTS) {
42 $cv->begin;
43 my $h; $h = simple_client GET => '/',
44 name => "($n)",
45 sub {
46 my ($body, $headers) = @_;
47 is $headers->{'Status'}, 200, "($n) Response OK";
48 is $headers->{'content-type'}, 'text/plain', "... ($n) is text";
49 is $body, 'Hello World', "... ($n) correct body";
50 $cv->end;
51 undef $h;
52 };
53 }
54
8496033a »
2010-09-06 Basic PSGI handler.
55 $cv->recv;
56 pass "all done";
Something went wrong with that request. Please try again.