Skip to content
Browse files

test error mode

  • Loading branch information...
1 parent 9b8e895 commit b6f26144712f3e55b487f01671cc5c8c8c64064c @moritz committed Jun 26, 2010
Showing with 14 additions and 1 deletion.
  1. +14 −1 t/basic.t
View
15 t/basic.t
@@ -90,13 +90,17 @@ if 0 {
{
my $error_hook_called = 0;
+ my $error_mode_called = 0;
class TestAppWithError is CGI::Application {
method BUILD { %.run-modes<throws_error> = 'throws_error' };
method throws_error() {
die "OH NOEZ";
}
method error(*@args) {
- $error_hook_called = 1;
+ $error_hook_called++;
+ }
+ method my_error_mode(*@args) {
+ $error_mode_called++;
}
}
@@ -105,6 +109,15 @@ if 0 {
dies_ok { $app.run() },
'when the run mode dies, the whole execution aborts';
ok $error_hook_called, 'and the error hook was called';
+ nok $error_mode_called, '... but error mode was not set';
+
+ # now test with error mode too
+ $error_hook_called = 0;
+ $error_mode_called = 0;
+ $app.error-mode = 'my_error_mode';
+ lives_ok { $app.run() }, 'Lives when run mode dies and error mode is set';
+ ok $error_hook_called, 'Error hook was called';
+ ok $error_mode_called, 'Error mode was called too';
}

0 comments on commit b6f2614

Please sign in to comment.
Something went wrong with that request. Please try again.