Skip to content

Commit

Permalink
fixed online tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Sep 1, 2012
1 parent 1cebd7a commit bdc7052
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions t/mojo/user_agent_online.t
Expand Up @@ -72,26 +72,26 @@ $ua = Mojo::UserAgent->new;
my $port = Mojo::IOLoop->generate_port;
my $tx = $ua->build_tx(GET => "http://localhost:$port");
$ua->start($tx);
ok !$tx->is_finished, 'transaction is not finished';
ok $tx->error, 'has error';
ok $tx->is_finished, 'transaction is finished';
ok $tx->error, 'has error';

# Connection refused (IPv4)
$tx = $ua->build_tx(GET => "http://127.0.0.1:$port");
$ua->start($tx);
ok !$tx->is_finished, 'transaction is not finished';
ok $tx->error, 'has error';
ok $tx->is_finished, 'transaction is finished';
ok $tx->error, 'has error';

# Connection refused (IPv6)
$tx = $ua->build_tx(GET => "http://[::1]:$port");
$ua->start($tx);
ok !$tx->is_finished, 'transaction is not finished';
ok $tx->error, 'has error';
ok $tx->is_finished, 'transaction is finished';
ok $tx->error, 'has error';

# Host does not exist
$tx = $ua->build_tx(GET => 'http://cdeabcdeffoobarnonexisting.com');
$ua->start($tx);
is $tx->error, "Couldn't connect", 'right error';
ok !$tx->is_finished, 'transaction is not finished';
ok $tx->is_finished, 'transaction is finished';

# Fresh user agent again
$ua = Mojo::UserAgent->new;
Expand Down Expand Up @@ -266,11 +266,11 @@ ok $tx->remote_port > 0, 'has local port';

# Connect timeout (non-routable address)
$tx = $ua->connect_timeout(0.5)->get('192.0.2.1');
ok !$tx->is_finished, 'transaction is not finished';
ok $tx->is_finished, 'transaction is finished';
is $tx->error, 'Connect timeout', 'right error';
$ua->connect_timeout(3);

# Request timeout (non-routable address)
$tx = $ua->request_timeout(0.5)->get('192.0.2.1');
ok !$tx->is_finished, 'transaction is not finished';
ok $tx->is_finished, 'transaction is finished';
is $tx->error, 'Request timeout', 'right error';

0 comments on commit bdc7052

Please sign in to comment.