Commit | Line | Data |
392e5076 |
1 | #!/usr/bin/env perl |
2 | use strict; |
3 | use warnings; |
4 | |
5 | no warnings 'redefine'; |
6 | |
7 | use FindBin; |
8 | use lib "$FindBin::Bin/lib"; |
9 | |
10 | use Test::More; |
11 | use Test::Output; |
12 | use Catalyst::Test 'TestApp'; |
13 | |
14 | my $get = sub { get(join '/', '/errors/signature_error_on_foo', @_) }; |
15 | my $subget = sub { get(join '/', '/sub_errors/signature_error_on_foo', @_) }; |
16 | my $modget = sub { get(join '/', '/sub_errors/signature_error_on_foo_modify', @_) }; |
17 | |
18 | |
19 | local *TestApp::debug = sub { 0 }; |
20 | |
392e5076 |
21 | stderr_like { |
22 | |
23 | like $get->('bar'), qr/come back later/i, 'normal handling of method validation error'; |
24 | |
25 | } qr/Validation failed/, 'method error throws validation error to error log'; |
26 | |
27 | stderr_like { |
28 | |
29 | like $subget->('bar'), qr/come back later/i, 'normal handling of method validation error (child)'; |
30 | |
31 | } qr/Validation failed/, 'method error throws validation error to error log (child)'; |
32 | |
33 | stderr_like { |
34 | |
35 | like $modget->('bar'), qr/come back later/i, 'normal handling of method validation error (modified)'; |
36 | |
37 | } qr/Validation failed/, 'method error throws validation error to error log (modified)'; |
38 | |
39 | is $get->('baz'), 'FOO BAR', 'make sure all works without any errors happening'; |
40 | is $subget->('baz'), 'FOO BAR', 'make sure all works without any errors happening (child)'; |
41 | is $modget->('baz'), 'FOO_MODIFY BAR', 'make sure all works without any errors happening (child)'; |
42 | |
43 | |
44 | local *TestApp::debug = sub { 1 }; |
45 | |
392e5076 |
46 | stderr_unlike { |
47 | |
48 | is $get->('baz'), 'FOO BAR', 'make sure all works without any errors happening in debug mode'; |
49 | |
50 | } qr/\[error\]/i, 'no errors in output'; |
51 | |
52 | stderr_unlike { |
53 | |
54 | is $subget->('baz'), 'FOO BAR', 'make sure all works without any errors happening in debug mode (child)'; |
55 | |
56 | } qr/\[error\]/i, 'no errors in output (child)'; |
57 | |
58 | stderr_unlike { |
59 | |
60 | is $modget->('baz'), 'FOO_MODIFY BAR', 'make sure all works without any errors happening in debug mode (modified)'; |
61 | |
62 | } qr/\[error\]/i, 'no errors in output (modified)'; |
63 | |
64 | |
65 | done_testing; |