File: multipath_lite_app.t

package info (click to toggle)
libmojolicious-perl 2.98%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 2,968 kB
  • sloc: perl: 10,178; sh: 48; makefile: 8
file content (62 lines) | stat: -rw-r--r-- 1,937 bytes parent folder | download
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
use Mojo::Base -strict;

# Disable IPv6 and libev
BEGIN {
  $ENV{MOJO_NO_IPV6} = 1;
  $ENV{MOJO_REACTOR} = 'Mojo::Reactor::Poll';
}

# "You are hereby conquered.
#  Please line up in order of how much beryllium it takes to kill you."
use Test::More tests => 30;

use Mojolicious::Lite;
use Test::Mojo;

# More paths with higher precedence
unshift @{app->renderer->paths}, app->home->rel_dir('templates2');
unshift @{app->static->paths},   app->home->rel_dir('public2');

# GET /twenty_three
get '/twenty_three' => '23';

# GET /fourty_two
get '/fourty_two' => '42';

# GET /yada
get '/yada' => {template => 'foo/yada'};

my $t = Test::Mojo->new;

# GET /twenty_three (templates)
$t->get_ok('/twenty_three')->status_is(200)
  ->header_is(Server         => 'Mojolicious (Perl)')
  ->header_is('X-Powered-By' => 'Mojolicious (Perl)')->content_is("23\n");

# GET /fourty_two (templates2)
$t->get_ok('/fourty_two')->status_is(200)
  ->header_is(Server         => 'Mojolicious (Perl)')
  ->header_is('X-Powered-By' => 'Mojolicious (Perl)')
  ->content_is("The answer is 42.\n");

# GET /hello.txt (public2)
$t->get_ok('/hello.txt')->status_is(200)
  ->header_is(Server         => 'Mojolicious (Perl)')
  ->header_is('X-Powered-By' => 'Mojolicious (Perl)')
  ->content_is("Also higher precedence!\n");

# GET /hello2.txt (public)
$t->get_ok('/hello2.txt')->status_is(200)
  ->header_is(Server         => 'Mojolicious (Perl)')
  ->header_is('X-Powered-By' => 'Mojolicious (Perl)')->content_is("X");

# GET /hello3.txt (public2)
$t->get_ok('/hello3.txt')->status_is(200)
  ->header_is(Server         => 'Mojolicious (Perl)')
  ->header_is('X-Powered-By' => 'Mojolicious (Perl)')
  ->content_is("Hello Mojo from... ALL GLORY TO THE HYPNOTOAD!\n");

# GET /yada (templates2)
$t->get_ok('/yada')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
  ->header_is('X-Powered-By' => 'Mojolicious (Perl)')
  ->content_is("Higher precedence!\n");