Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
added timeout tests for Mojo::UserAgent
  • Loading branch information
kraih committed Jan 25, 2012
1 parent ebb6741 commit 0f2743b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Changes
@@ -1,6 +1,6 @@
This file documents the revision history for Perl extension Mojolicious.

2.46 2012-01-24 00:00:00
2.46 2012-01-25 00:00:00
- Added EXPERIMENTAL request_timeout attribute to Mojo::UserAgent.
- Added EXPERIMENTAL text_after and text_before methods to Mojo::DOM.
- Improved all uses of syswrite to be more defensive. (bduggan, sri)
Expand Down
13 changes: 12 additions & 1 deletion t/mojo/user_agent_online.t
Expand Up @@ -10,7 +10,7 @@ use Test::More;

plan skip_all => 'set TEST_ONLINE to enable this test (developer only!)'
unless $ENV{TEST_ONLINE};
plan tests => 105;
plan tests => 109;

# "So then I said to the cop, "No, you're driving under the influence...
# of being a jerk"."
Expand Down Expand Up @@ -331,3 +331,14 @@ is $tx2->res->code, 200, 'right status';
is $tx3->res->code, 200, 'right status';
is $tx4->res->code, 200, 'right status';
like $tx2->res->content->asset->slurp, qr/Perl/i, 'right content';

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

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

0 comments on commit 0f2743b

Please sign in to comment.