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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
|
use Mojo::Base -strict;
use utf8;
# Disable IPv6 and libev
BEGIN {
$ENV{MOJO_MODE} = 'testing';
$ENV{MOJO_NO_IPV6} = 1;
$ENV{MOJO_REACTOR} = 'Mojo::Reactor::Poll';
}
use Test::More tests => 39;
# "I wax my rocket every day!"
use Mojolicious::Lite;
use Test::Mojo;
# Mount full external application a few times
use FindBin;
my $external = "$FindBin::Bin/external/script/my_app";
plugin Mount => {'/x/1' => $external};
plugin(Mount => ('/x/♥' => $external));
plugin Mount => {'MOJOLICIO.US/' => $external};
plugin(Mount => ('*.foo-bar.de/♥/123' => $external));
# GET /hello
get '/hello' => 'works';
my $t = Test::Mojo->new;
# GET /hello
$t->get_ok('/hello')->status_is(200)->content_is("Hello from the main app!\n");
# GET /x/1 (external app)
$t->get_ok('/x/1')->status_is(200)->content_is('too%21');
# GET /x/1/index.html (external app)
$t->get_ok('/x/1/index.html')->status_is(200)
->content_is("External static file!\n");
# GET /x/1/test (external app)
$t->get_ok('/x/1/test')->status_is(200)->content_is('works%21');
# GET /x/♥ (external app)
$t->get_ok('/x/♥')->status_is(200)->content_is('too%21');
# GET /x/♥/index.html (external app)
$t->get_ok('/x/♥/index.html')->status_is(200)
->content_is("External static file!\n");
# GET /x/♥/test (external app)
$t->get_ok('/x/♥/test')->status_is(200)->content_is('works%21');
# GET / (external app with domain)
$t->get_ok('/' => {Host => 'mojolicio.us'})->status_is(200)
->content_is('too%21');
# GET /index.html (external app with domain)
$t->get_ok('/index.html' => {Host => 'mojolicio.us'})->status_is(200)
->content_is("External static file!\n");
# GET /test (external app with domain)
$t->get_ok('/test' => {Host => 'mojolicio.us'})->status_is(200)
->content_is('works%21');
# GET /♥/123/ (external app with a bit of everything)
$t->get_ok('/♥/123/' => {Host => 'test.foo-bar.de'})->status_is(200)
->content_is('too%21');
# GET /♥/123/index.html (external app with a bit of everything)
$t->get_ok('/♥/123/index.html' => {Host => 'test.foo-bar.de'})
->status_is(200)->content_is("External static file!\n");
# GET /♥/123/test (external app with a bit of everything)
$t->get_ok('/♥/123/test' => {Host => 'test.foo-bar.de'})->status_is(200)
->content_is('works%21');
__DATA__
@@ works.html.ep
Hello from the main app!
|