Debian Codegraph @

t/multi_apps.t

raw
1 use strict;
2 use warnings;
3 use Test::More;
4 use Plack::Builder;
5 use Plack::Test;
6 use HTTP::Request::Common;
7
8 {
9 package MyTestWiki;
10 use Dancer2;
11 get '/' => sub { __PACKAGE__ };
12 get '/wiki' => sub {'WIKI'};
13
14 package MyTestForum;
15 use Dancer2;
16 get '/' => sub { __PACKAGE__ };
17 get '/forum' => sub {'FORUM'};
18 }
19
20 {
21 my $app = builder {
22 mount '/wiki' => MyTestWiki->to_app;
23 mount '/forum' => MyTestForum->to_app;
24 };
25
26 isa_ok( $app, 'CODE', 'Got app' );
27
28 test_psgi $app, sub {
29 my $cb = shift;
30
31 is( $cb->( GET '/wiki' )->content, 'MyTestWiki', "Got wiki root" );
32 is( $cb->( GET '/forum' )->content, 'MyTestForum', "Got forum root" );
33 };
34 }
35
36 {
37 my $app = Dancer2->psgi_app;
38 isa_ok( $app, 'CODE', 'Got app' );
39
40 test_psgi $app, sub {
41 my $cb = shift;
42
43 is( $cb->( GET '/wiki' )->content, 'WIKI', 'Got /wiki path' );
44 is( $cb->( GET '/forum' )->content, 'FORUM', 'Got /forum path' );
45 };
46 }
47
48 done_testing;