Skip to content

Commit

Permalink
added graceful shutdown test for Mojo::IOLoop
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Feb 17, 2012
1 parent 857b5f2 commit eb23659
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion t/mojo/ioloop.t
Expand Up @@ -6,7 +6,7 @@ BEGIN {
$ENV{MOJO_IOWATCHER} = 'Mojo::IOWatcher';
}

use Test::More tests => 33;
use Test::More tests => 35;

# "Marge, you being a cop makes you the man!
# Which makes me the woman, and I have no interest in that,
Expand Down Expand Up @@ -251,6 +251,20 @@ ok length($server) > length($server_after), 'stream has been resumed';
is $client, $client_after, 'stream was writable while paused';
is $client, 'works!', 'full message has been written';

# Graceful shutdown
$err = '';
$loop = Mojo::IOLoop->new(max_connections => 0);
$loop->drop($loop->client({port => $loop->generate_port}));
$loop->timer(
1 => sub {
shift->stop;
$err = 'failed!';
}
);
$loop->start;
ok !$err, 'no error';
is $loop->max_connections, 0, 'right value';

# Defaults
is Mojo::IOLoop::Client->new->iowatcher, Mojo::IOLoop->singleton->iowatcher,
'right default';
Expand Down

0 comments on commit eb23659

Please sign in to comment.