App-Easer
view release on metacpan or search on metacpan
t/V2/01-single.t view on Meta::CPAN
force_auto_children => 1,
};
my @tests = (
{
name => 'no input, just defaults',
cmdline => [],
env => {},
outcome => {conf => {bar => 'buzz'}, args => []},
},
{
name => 'env only for foo',
cmdline => [],
env => {GALOOK_FOO => 1},
outcome => {conf => {foo => 1, bar => 'buzz'}, args => []},
},
{
name => 'env only (foo & bar)',
cmdline => [],
env => {GALOOK_FOO => 1, GALOOK_BAR => 'BuZz'},
outcome => {conf => {foo => 1, bar => 'BuZz'}, args => []},
},
{
name => 'env + cmdline for foo',
cmdline => [qw< --no-foo >],
env => {GALOOK_FOO => 1},
outcome => {conf => {foo => '', bar => 'buzz'}, args => []},
},
{
name => 'env + cmdline',
cmdline => [qw< --no-foo --bar BAAZ >],
env => {GALOOK_FOO => 1},
outcome => {conf => {foo => '', bar => 'BAAZ'}, args => []},
},
);
for my $test (@tests) {
my ($cmdline, $env, $outcome, $name) =
$test->@{qw< cmdline env outcome name >};
delete @ENV{qw< GALOOK_FOO GALOOK_BAR >};
$ENV{$_} = $env->{$_} for keys(($env // {})->%*);
cleanup();
run($app, $0 => $cmdline->@*);
check_last_run($outcome, $name);
} ## end for my $test (@tests)
stdout_like { run($app, $0 => 'help') } qr{(?mxs:
example \s+ command .*?
An \s+ example \s+ command .*?
--foo .*
GALOOK_BAR .*?
help .*?
commands .*?
)}, 'output of help command';
stdout_like { run($app, $0 => 'commands') } qr{(?mxs:
help .*?
commands .*?
)}, 'output of help command';
throws_ok { run($app, $0 => 'inexistent') } qr{(?mxs:
cannot .*? inexistent
)}, 'inexistent command generates complaint';
done_testing();
( run in 1.300 second using v1.01-cache-2.11-cpan-5837b0d9d2c )