Skip to content

Commit

Permalink
more app_url tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jul 10, 2012
1 parent 1d55e71 commit 69a7fb8
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions t/mojo/user_agent.t
Expand Up @@ -6,7 +6,7 @@ BEGIN {
$ENV{MOJO_REACTOR} = 'Mojo::Reactor::Poll';
}

use Test::More tests => 82;
use Test::More tests => 86;

# "The strong must protect the sweet."
use Mojo::IOLoop;
Expand Down Expand Up @@ -289,7 +289,7 @@ is $tx->res->code, 200, 'right status';
is $tx->res->body, '0123456789', 'right content';
is $stream, 1, 'no leaking subscribers';

# Nested keep alive
# GET / (nested non-blocking requests after blocking one, with custom URL)
my @kept_alive;
$ua->get(
$ua->app_url => sub {
Expand All @@ -313,17 +313,15 @@ $ua->get(
Mojo::IOLoop->start;
is_deeply \@kept_alive, [undef, 1, 1], 'connections kept alive';

# Simple nested keep alive with timers
# GET / (simple nested non-blocking requests with timers)
@kept_alive = ();
$ua->get(
'/',
sub {
'/' => sub {
push @kept_alive, pop->kept_alive;
Mojo::IOLoop->timer(
0.25 => sub {
$ua->get(
'/',
sub {
'/' => sub {
push @kept_alive, pop->kept_alive;
Mojo::IOLoop->timer(0.25 => sub { Mojo::IOLoop->stop });
}
Expand All @@ -335,6 +333,13 @@ $ua->get(
Mojo::IOLoop->start;
is_deeply \@kept_alive, [1, 1], 'connections kept alive';

# GET / (blocking request after non-blocking one, with custom URL)
$tx = $ua->get($ua->app_url);
ok $tx->success, 'successful';
ok !$tx->kept_alive, 'kept connection not alive';
is $tx->res->code, 200, 'right status';
is $tx->res->body, 'works!', 'right content';

# Premature connection close
my $port = Mojo::IOLoop->generate_port;
my $id = Mojo::IOLoop->server(
Expand Down

0 comments on commit 69a7fb8

Please sign in to comment.