X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Faggregate%2Funit_core_script_fastcgi.t;h=2dde9d9b90b3fc360222907c61c879554db9b1db;hb=89222c2a9136170aa4012fbf3c7b804abeff2463;hp=b5d3ea49e236e0b033bedfc8657d7468cd3b4caa;hpb=e1d59dc47052af927345195b14f9163f6dffd591;p=catagits%2FCatalyst-Runtime.git diff --git a/t/aggregate/unit_core_script_fastcgi.t b/t/aggregate/unit_core_script_fastcgi.t index b5d3ea4..2dde9d9 100644 --- a/t/aggregate/unit_core_script_fastcgi.t +++ b/t/aggregate/unit_core_script_fastcgi.t @@ -9,7 +9,48 @@ use Test::Exception; use Catalyst::Script::FastCGI; -my $testopts; +local our $fake_handler = \42; + +{ + package TestFastCGIScript; + use Moose; + use namespace::autoclean; + + extends 'Catalyst::Script::FastCGI'; + + # Avoid loading the real plack engine, as that will load FCGI and fail if + # it's not there. We don't really need a full engine anyway as the overriden + # 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; + lives_ok { + TestFastCGIScript->new_with_options(application_name => 'TestAppToTestScripts')->run; + } "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'; + is_deeply \@TestAppToTestScripts::RUN_ARGS, $resultarray, "is_deeply comparison"; +} + +# Returns the hash expected when no flags are passed +sub opthash { + return { + (map { ($_ => undef) } qw(pidfile keep_stderr detach nproc manager)), + proc_title => 'perl-fcgi-pm [TestAppToTestScripts]', + @_, + }; +} + # Test default (no opts/args behaviour) testOption( [ qw// ], [undef, opthash()] ); @@ -39,29 +80,7 @@ testOption( [ qw/-e/ ], [undef, opthash(keep_stderr => 1)] ); testOption( [ qw/--nproc 6/ ], [undef, opthash(nproc => 6)] ); testOption( [ qw/--n 6/ ], [undef, opthash(nproc => 6)] ); -done_testing; - -sub testOption { - my ($argstring, $resultarray) = @_; - - local @ARGV = @$argstring; - local @TestAppToTestScripts::RUN_ARGS; - lives_ok { - Catalyst::Script::FastCGI->new_with_options(application_name => 'TestAppToTestScripts')->run; - } "new_with_options"; - # First element of RUN_ARGS will be the script name, which we don't care about - shift @TestAppToTestScripts::RUN_ARGS; - is_deeply \@TestAppToTestScripts::RUN_ARGS, $resultarray, "is_deeply comparison"; -} +# proc_title +testOption( [ qw/--proc_title foo/ ], [undef, opthash(proc_title => 'foo')] ); -# Returns the hash expected when no flags are passed -sub opthash { - return { - pidfile => undef, - keep_stderr => undef, - detach => undef, - nproc => undef, - manager => undef, - @_, - }; -} +done_testing;