File: cascade.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 (29 lines) | stat: -rw-r--r-- 729 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
use Plack::Test;
use Test::More;

use Plack::App::Cascade;
use Plack::App::URLMap;
use Plack::App::File;
use HTTP::Request::Common;

my $cascade = Plack::App::Cascade->new;
$cascade->add( Plack::App::File->new(root => "t/Plack-Middleware")->to_app );
$cascade->add( Plack::App::File->new(root => "t/Plack-Util")->to_app );

my $app = Plack::App::URLMap->new;
$app->map("/static", $cascade);

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

    my $res = $cb->(GET "http://localhost/static/access_log.t");
    is $res->code, 200;

    $res = $cb->(GET "http://localhost/static/foo");
    is $res->code, 404;

    $res = $cb->(GET "http://localhost/static/foreach.t");
    is $res->code, 200;
};

done_testing;