From: Mark Ellis Date: Mon, 27 Jan 2014 21:41:20 +0000 (+0000) Subject: Added an extra test that dies in the middle of a chain X-Git-Tag: 5.90060~12^2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ce22898b619f9043604e7de3d97262364b5b057b;p=catagits%2FCatalyst-Runtime.git Added an extra test that dies in the middle of a chain --- diff --git a/t/aggregate/live_component_controller_action_chained.t b/t/aggregate/live_component_controller_action_chained.t index 99ea3c7..f0cbc6a 100644 --- a/t/aggregate/live_component_controller_action_chained.t +++ b/t/aggregate/live_component_controller_action_chained.t @@ -776,6 +776,25 @@ sub run_tests { { my @expected = qw[ TestApp::Controller::Action::Chained->begin + TestApp::Controller::Action::Chained->chain_error_a + TestApp::Controller::Action::Chained->end + ]; + + my $expected = join( ", ", @expected ); + + ok( my $response = request('http://localhost/chained/chain_error/1/end/2'), + "Break a chain in the middle" ); + is( $response->header('X-Catalyst-Executed'), + $expected, 'Executed actions' ); + is( $response->content, 'FATAL ERROR: break in the middle of a chain', 'Content OK' ); + } + + # + # Test dieing in the middle of a chain. + # + { + my @expected = qw[ + TestApp::Controller::Action::Chained->begin TestApp::Controller::Action::Chained->chain_die_a TestApp::Controller::Action::Chained->end ]; @@ -786,7 +805,7 @@ sub run_tests { "Break a chain in the middle" ); is( $response->header('X-Catalyst-Executed'), $expected, 'Executed actions' ); - is( $response->content, 'FATAL ERROR: break in the middle of a chain', 'Content OK' ); + is( $response->content, 'FATAL ERROR: Caught exception in TestApp::Controller::Action::Chained->chain_die_a "die in the middle of a chain"', 'Content OK' ); } # diff --git a/t/lib/TestApp/Controller/Action/Chained.pm b/t/lib/TestApp/Controller/Action/Chained.pm index 2af1ec6..4c02130 100644 --- a/t/lib/TestApp/Controller/Action/Chained.pm +++ b/t/lib/TestApp/Controller/Action/Chained.pm @@ -143,10 +143,19 @@ sub chain_dt_a :Chained :PathPart('chained/chain_dt') :CaptureArgs(1) { sub chain_dt_b :Chained('chain_dt_a') :PathPart('end') :Args(1) { } # +# Error in the middle of a chain +# +sub chain_error_a :Chained :PathPart('chained/chain_error') :CaptureArgs(1) { + $_[1]->error( 'break in the middle of a chain' ); +} + +sub chain_error_b :Chained('chain_error_a') :PathPart('end') :Args(1) {} + +# # Die in the middle of a chain # sub chain_die_a :Chained :PathPart('chained/chain_die') :CaptureArgs(1) { - $_[1]->error( 'break in the middle of a chain' ); + die( "die in the middle of a chain\n" ); } sub chain_die_b :Chained('chain_die_a') :PathPart('end') :Args(1) {}