From: Dave Rolsky Date: Tue, 3 May 2011 16:28:42 +0000 (-0500) Subject: Add a test to make sure that a die in a Controller's end sub is propogated as a 500... X-Git-Tag: 5.80033~20 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=5a39616b06890f0f52089a93a0714159ee2066ec;hp=554c758740d1f5b5b548b777e7180e556f9f6a55 Add a test to make sure that a die in a Controller's end sub is propogated as a 500 error --- diff --git a/t/aggregate/live_component_controller_action_die_in_end.t b/t/aggregate/live_component_controller_action_die_in_end.t new file mode 100644 index 0000000..b43aafe --- /dev/null +++ b/t/aggregate/live_component_controller_action_die_in_end.t @@ -0,0 +1,29 @@ +#!perl + +use strict; +use warnings; + +use FindBin; +use lib "$FindBin::Bin/../lib"; + +our $iters; + +BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; } + +use Test::More tests => 2*$iters; +use Catalyst::Test 'TestApp'; + +if ( $ENV{CAT_BENCHMARK} ) { + require Benchmark; + Benchmark::timethis( $iters, \&run_tests ); +} +else { + for ( 1 .. $iters ) { + run_tests(); + } +} + +sub run_tests { + ok( my $response = request('http://localhost/action/die_in_end'), 'Request' ); + ok( !$response->is_success, 'generates a 500 error' ); +} diff --git a/t/lib/TestApp/Controller/Action/DieInEnd.pm b/t/lib/TestApp/Controller/Action/DieInEnd.pm new file mode 100644 index 0000000..61f4b2c --- /dev/null +++ b/t/lib/TestApp/Controller/Action/DieInEnd.pm @@ -0,0 +1,16 @@ +package TestApp::Controller::Action::DieInEnd; + +use strict; +use base 'TestApp::Controller::Action'; + +sub end : Private { + my ( $self, $c ) = @_; + die "I'm ending with death"; +} + +sub default : Private { + my ( $self, $c ) = @_; + $c->forward('TestApp::View::Dump::Request'); +} + +1;