-
Notifications
You must be signed in to change notification settings - Fork 576
/
commands.t
66 lines (58 loc) · 1.64 KB
/
commands.t
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
use Mojo::Base -strict;
use Test::More tests => 10;
use FindBin;
use lib "$FindBin::Bin/lib";
# "I'm not a robot!
# I don't like having discs crammed into me, unless they're Oreos.
# And then, only in the mouth."
use Mojolicious::Commands;
# Environment detection
my $commands = Mojolicious::Commands->new;
{
local $ENV{PLACK_ENV} = 'production';
is $commands->detect, 'psgi', 'right environment';
}
{
local $ENV{PATH_INFO} = '/test';
is $commands->detect, 'cgi', 'right environment';
}
{
local $ENV{GATEWAY_INTERFACE} = 'CGI/1.1';
is $commands->detect, 'cgi', 'right environment';
}
# Run command
is ref Mojolicious::Commands->run('psgi'), 'CODE', 'right reference';
# Start application
{
local $ENV{MOJO_APP_LOADER} = 1;
local $ENV{MOJO_APP};
is ref Mojolicious::Commands->start_app('MojoliciousTest'),
'MojoliciousTest', 'right class';
}
{
local $ENV{MOJO_APP_LOADER} = 1;
local $ENV{MOJO_APP} = 'MojoliciousTest';
is ref Mojolicious::Commands->start, 'MojoliciousTest', 'right class';
}
# Start application with command
{
local $ENV{MOJO_APP};
is ref Mojolicious::Commands->start_app(MojoliciousTest => 'psgi'), 'CODE',
'right reference';
}
{
local $ENV{MOJO_APP} = 'MojoliciousTest';
is ref Mojolicious::Commands->start('psgi'), 'CODE', 'right reference';
}
# Start application with application specific command
my $app;
{
local $ENV{MOJO_APP_LOADER} = 1;
$app = Mojolicious::Commands->start_app('MojoliciousTest');
}
is $app->start('test_command'), 'works!', 'right result';
{
local $ENV{MOJO_APP};
is(Mojolicious::Commands->start_app(MojoliciousTest => 'test_command'),
'works!', 'right result');
}