Catalyst-Runtime
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
t/aggregate/unit_core_script_cgi.t view on Meta::CPAN
use warnings;
use FindBin qw/$Bin/;
use lib "$Bin/../lib";
use Test::More;
use Test::Fatal;
use Catalyst::Script::CGI;
local @ARGV;
is exception {
Catalyst::Script::CGI->new_with_options(application_name => 'TestAppToTestScripts')->run;
}, undef, "new_with_options";
shift @TestAppToTestScripts::RUN_ARGS;
my $server = pop @TestAppToTestScripts::RUN_ARGS;
like ref($server), qr/^Plack::Handler/, 'Is a Plack::Handler';
is ref(delete($TestAppToTestScripts::RUN_ARGS[0]->{argv})), 'ARRAY';
is ref(delete($TestAppToTestScripts::RUN_ARGS[0]->{extra_argv})), 'ARRAY';
is_deeply \@TestAppToTestScripts::RUN_ARGS, [{}], "no args";
t/aggregate/unit_core_script_create.t view on Meta::CPAN
}
{
package TestHelperClass::False;
use Moose;
extends 'TestHelperClass';
sub _mk_component_return { 0 }
}
{
local $TestCreateScript::help;
local @ARGV;
is exception {
TestCreateScript->new_with_options(application_name => 'TestAppToTestScripts', helper_class => 'TestHelperClass')->run;
}, undef, "no argv";
ok $TestCreateScript::help, 'Exited with usage info';
}
{
local $TestCreateScript::help;
local @ARGV = 'foo';
local @TestHelperClass::ARGS;
local %TestHelperClass::p;
is exception {
TestCreateScript->new_with_options(application_name => 'TestAppToTestScripts', helper_class => 'TestHelperClass')->run;
}, undef, "with argv";
ok !$TestCreateScript::help, 'Did not exit with usage into';
is_deeply \@TestHelperClass::ARGS, ['TestAppToTestScripts', 'foo'], 'Args correct';
is_deeply \%TestHelperClass::p, { '.newfiles' => 1, mech => undef }, 'Params correct';
}
{
local $TestCreateScript::help;
local @ARGV = 'foo';
local @TestHelperClass::ARGS;
local %TestHelperClass::p;
is exception {
TestCreateScript->new_with_options(application_name => 'TestAppToTestScripts', helper_class => 'TestHelperClass::False')->run;
}, undef, "with argv";
ok $TestCreateScript::help, 'Did exit with usage into as mk_component returned false';
is_deeply \@TestHelperClass::ARGS, ['TestAppToTestScripts', 'foo'], 'Args correct';
is_deeply \%TestHelperClass::p, { '.newfiles' => 1, mech => undef }, 'Params correct';
}
t/aggregate/unit_core_script_fastcgi.t view on Meta::CPAN
# MyApp->run will just capture its arguments and return without delegating
# to the engine to run things.
override load_engine => sub { $fake_handler };
__PACKAGE__->meta->make_immutable;
}
sub testOption {
my ($argstring, $resultarray) = @_;
local @ARGV = @$argstring;
local @TestAppToTestScripts::RUN_ARGS;
is exception {
TestFastCGIScript->new_with_options(application_name => 'TestAppToTestScripts')->run;
}, undef, "new_with_options";
# First element of RUN_ARGS will be the script name, which we don't care about
shift @TestAppToTestScripts::RUN_ARGS;
my $server = pop @TestAppToTestScripts::RUN_ARGS;
is $server, $fake_handler, 'Loaded Plack handler gets passed to the app';
t/aggregate/unit_core_script_help.t view on Meta::CPAN
with 'Catalyst::ScriptRole';
our $help;
sub print_usage_text { $help++ }
}
test('--help');
test('-?');
sub test {
local $TestHelpScript::help;
local @ARGV = (@_);
is exception {
TestHelpScript->new_with_options(application_name => 'TestAppToTestScripts')->run;
}, undef, 'Lives';
ok $TestHelpScript::help, 'Got help';
}
done_testing;
t/aggregate/unit_core_script_run_options.t view on Meta::CPAN
use_ok('Catalyst::ScriptRunner');
use_ok('ScriptTestApp');
is ScriptTestApp->run_options, undef;
my ($fh, $fn) = tempfile();
binmode( $fh );
binmode( STDOUT );
local @ARGV = ();
local %ENV;
my $saved;
open( $saved, '>&'. STDOUT->fileno )
or croak("Can't dup stdout: $!");
open( STDOUT, '>&='. $fh->fileno )
or croak("Can't open stdout: $!");
local $SIG{__WARN__} = sub {}; # Shut up warnings...
try { Catalyst::ScriptRunner->run('ScriptTestApp', 'CGI'); pass("Ran ok") }
catch { fail "Failed to run $_" };
t/aggregate/unit_core_script_server.t view on Meta::CPAN
ok $app->restart, 'App is in restart mode';
my $args = {$app->_restarter_args};
is_deeply delete $args->{argv}, $argstring, 'argv is arg string';
is ref(delete $args->{start_sub}), 'CODE', 'Closure to start app present';
is_deeply $args, $resultarray, "is_deeply comparison of restarter args " . join(' ', @$argstring);
}
sub _build_testapp {
my ($argstring, $resultarray) = @_;
local @ARGV = @$argstring;
local @TestAppToTestScripts::RUN_ARGS;
my $i;
try {
$i = Catalyst::Script::Server->new_with_options(application_name => 'TestAppToTestScripts');
pass "new_with_options " . join(' ', @$argstring);
}
catch {
fail "new_with_options " . join(' ', @$argstring) . " " . $_;
};
ok $i;
t/unit_core_script_test.t view on Meta::CPAN
sub run_test {
my $url = shift;
my ($fh, $fn) = tempfile();
binmode( $fh );
binmode( STDOUT );
{
local @ARGV = ($url);
my $i;
is exception {
$i = Catalyst::Script::Test->new_with_options(application_name => 'TestApp');
}, undef, "new_with_options";
ok $i;
my $saved;
open( $saved, '>&'. STDOUT->fileno )
or croak("Can't dup stdout: $!");
open( STDOUT, '>&='. $fh->fileno )
or croak("Can't open stdout: $!");
view all matches for this distributionview release on metacpan - search on metacpan
( run in 0.613 second using v1.00-cache-2.02-grep-82fe00e-cpan-c9a218a2bbc )