File: hello.t

package info (click to toggle)
libhtml-mason-psgihandler-perl 0.53-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, forky, sid, trixie
  • size: 168 kB
  • sloc: perl: 162; makefile: 2
file content (37 lines) | stat: -rw-r--r-- 818 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
35
36
37
use strict;
use FindBin;
use Test::More;
use Plack::Test;

use HTML::Mason::PSGIHandler;

my $h = HTML::Mason::PSGIHandler->new(
    comp_root => $FindBin::Bin,
);

my @apps = (
  sub { $h->handle_psgi(@_) },
  $h->as_psgi,
  HTML::Mason::PSGIHandler->new_psgi(comp_root => $FindBin::Bin),
);

for my $app (@apps) {
    test_psgi app => $app, client => sub {
        my $cb = shift;
        my $res = $cb->(
            HTTP::Request->new(GET => "http://localhost/hello.mhtml?foo=bar")
        );
        is $res->code, 200, 'got 200 response';
        like $res->content, qr/Hello World Foo/;
        like $res->content, qr/foo,bar/;

        $res = $cb->(
            HTTP::Request->new(GET => "http://localhost/hello.mhtml?403=1")
        );
        is $res->code, 403, 'got 403 response';

    }
}

done_testing;