File: wrapcgi.t

package info (click to toggle)
libplack-perl 1.0050-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,484 kB
  • sloc: perl: 5,289; makefile: 4; sh: 4; javascript: 1
file content (37 lines) | stat: -rw-r--r-- 961 bytes parent folder | download | duplicates (7)
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
35
36
37
use strict;
use Test::More;
plan skip_all => "Hangs on Windows" if $^O eq 'MSWin32'; 
use Test::Requires { 'CGI::Emulate::PSGI' => 0.06, 'CGI::Compile' => 0.03 };
use Plack::Test;
use HTTP::Request::Common;
use Plack::App::WrapCGI;
use IO::File;
use File::Temp;

my $app = Plack::App::WrapCGI->new(script => "t/Plack-Middleware/cgi-bin/hello.cgi")->to_app;

test_psgi app => $app, client => sub {
    my $cb = shift;

    my $res = $cb->(GET "http://localhost/?name=foo");
    is $res->code, 200;
    is $res->content, "Hello foo counter=1";

    $res = $cb->(GET "http://localhost/?name=bar");
    is $res->code, 200;
    is $res->content, "Hello bar counter=2";
};

$app = Plack::App::WrapCGI->new(
  script => "t/Plack-Middleware/cgi-bin/cgi_dir.cgi",
  execute => 1)->to_app;

test_psgi app => $app, client => sub {
    my $cb = shift;

    my $res = $cb->(GET "http://localhost/?");
    is $res->code, 200;
    is $res->content, "MATCH";
};

done_testing;