Skip to content

Instantly share code, notes, and snippets.

@Logioniz
Created May 21, 2015 07:21
Show Gist options
  • Save Logioniz/8d4c49cb649ecc116253 to your computer and use it in GitHub Desktop.
Save Logioniz/8d4c49cb649ecc116253 to your computer and use it in GitHub Desktop.
Mojo test inactivity_timeout long operation.
use Mojo::Base -strict;
use Mojo::IOLoop;
use Mojolicious::Lite;
use Test::More;
use Test::Mojo;
get '/' => sub {
my $c = shift->render_later;
$c->inactivity_timeout(40);
$c->delay(
sub { Mojo::IOLoop->timer(30 => shift->begin) },
sub { $c->render(json => {result => 'ok'}) }
);
};
my $t = Test::Mojo->new;
$t->ua->inactivity_timeout(40);
$t->ua->max_connections(0);
$t->get_ok('/')->status_is(200)->json_is('/result' => 'ok');
done_testing();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment