Catch timeouts in proxy
Change-Id: If015c50aafd79fa7aaa914da3dcd335a4c07c3b0
diff --git a/t/proxy.t b/t/proxy.t
index 2e2f922..41b0acf 100644
--- a/t/proxy.t
+++ b/t/proxy.t
@@ -28,7 +28,8 @@
}
);
# Configure fake backend
-$fake_backend->pattern->defaults->{app}->log($t->app->log);
+my $fake_app = $fake_backend->pattern->defaults->{app};
+$fake_app->log($t->app->log);
# Globally set server
$t->app->ua->server->app($t->app);
@@ -90,6 +91,26 @@
->json_is('/token_type', 'Bearer')
;
+# Create long-running route
+$fake_app->routes->get('/v1.0/longwait')->to(
+ cb => sub {
+ my $c = shift;
+
+ $c->render_later;
+ Mojo::IOLoop->timer(
+ 5 => sub {
+ return $c->render(text => 'okay');
+ }
+ );
+ });
+
+# Set proxy timeout
+$t->app->ua->inactivity_timeout(1);
+
+$t->get_ok('/api/v1.0/longwait')
+ ->status_is(400)
+ ->content_is('Proxy error: Inactivity timeout')
+ ;
done_testing;
__END__