summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--t/tests/success-failure.t27
1 files changed, 23 insertions, 4 deletions
diff --git a/t/tests/success-failure.t b/t/tests/success-failure.t
index c537627..5a1a999 100644
--- a/t/tests/success-failure.t
+++ b/t/tests/success-failure.t
@@ -8,8 +8,6 @@ use IO::Async::Loop;
use IO::Async::Test;
use HTTP::Request;
use HTTP::Message::PSGI;
-use Plack::Util;
-use Plack::Builder;
use HTTP::Exception;
use Test2::Bundle::Extended;
@@ -79,8 +77,6 @@ sub run_test {
wait_for { $res } if $use_loop;
- Plack::Util::header_remove($res->[1],'X-Request-Id');
-
is(
$res,
$cases{$c},
@@ -94,4 +90,27 @@ sub run_test {
subtest 'with loop' => sub { run_test(1) };
subtest 'without loop' => sub { run_test(0) };
+package My::PSGI {
+ use Moo;
+ extends 'IO::Async::PSGI';
+
+ sub on_app_failure {
+ my ($self,$env,$exc,@details) = @_;
+
+ if ($exc =~ /^Expected/) {
+ return [ 501, [], ['something special from '.$env->{REQUEST_URI}] ];
+ }
+ return $self->next::method($env,$exc,@details);
+ }
+};
+
+for my $fail (qw(my/fail /my/fail /my//fail exception /exception)) {
+ $cases{$fail} = [501, [], ["something special from /$fail"] ];
+}
+delete @cases{qw(fail /fail)};
+$psgi = My::PSGI->new({app=>$app_f});
+$app = $psgi->psgi_app;
+
+subtest 'custom failure handler' => sub { run_test(1) };
+
done_testing;