File: cgi.t

package info (click to toggle)
libplack-perl 0.9941-1%2Bdeb6u1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze-lts
  • size: 1,472 kB
  • ctags: 600
  • sloc: perl: 7,155; makefile: 2
file content (34 lines) | stat: -rw-r--r-- 659 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
use strict;
use warnings;
use Test::Requires {
    'HTTP::Request::AsCGI' => 1.2,
};
use Test::More;
use FindBin;
use HTTP::Request::AsCGI;
use URI::Escape;
use Plack;
use Plack::Handler::CGI;
use Plack::Test::Suite;

Plack::Test::Suite->runtests(sub {
    my ($name, $test, $handler) = @_;

    note $name;
    my $cb = sub {
        my $req = shift;

        my $cgi = HTTP::Request::AsCGI->new($req);
        my $c = $cgi->setup;
        $ENV{SCRIPT_NAME} = '/plack_test.cgi';
        eval { Plack::Handler::CGI->new->run($handler) };
        my $res = $c->response;
        $res->request($req);

        $res;
    };

    $test->($cb);
});

done_testing;