Skip to content

Commit

Permalink
made online tests more reliable
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Apr 24, 2013
1 parent 838ee10 commit 9aeb94f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
2 changes: 1 addition & 1 deletion lib/Mojo/UserAgent.pm
Expand Up @@ -517,7 +517,7 @@ Mojo::UserAgent - Non-blocking I/O HTTP and WebSocket user agent
say $ua->get('www.☃.net?hello=there' => {DNT => 1})->res->body;
# Form POST with exception handling
my $tx = $ua->post('search.cpan.org/search' => form => {q => 'mojo'});
my $tx = $ua->post('https://metacpan.org/search' => form => {q => 'mojo'});
if (my $res = $tx->success) { say $res->body }
else {
my ($err, $code) = $tx->error;
Expand Down
28 changes: 13 additions & 15 deletions t/mojo/user_agent_online.t
Expand Up @@ -153,7 +153,7 @@ is h('mojolicio.us')->body, '', 'no content';
is p('mojolicio.us/lalalala')->code, 404, 'right status';
is g('http://mojolicio.us')->code, 200, 'right status';
is p('http://mojolicio.us')->code, 404, 'right status';
my $res = p('search.cpan.org/search' => form => {query => 'mojolicious'});
my $res = p('https://metacpan.org/search' => form => {q => 'mojolicious'});
like $res->body, qr/Mojolicious/, 'right content';
is $res->code, 200, 'right status';

Expand Down Expand Up @@ -215,23 +215,21 @@ like $ua->ioloop->stream($tx->connection)
$ua = Mojo::UserAgent->new;

# Simple keep-alive form POST
$tx = $ua->post(
'http://search.cpan.org/search' => form => {query => 'mojolicious'});
$tx = $ua->post('https://metacpan.org/search' => form => {q => 'mojolicious'});
is $tx->req->method, 'POST', 'right method';
is $tx->req->url, 'http://search.cpan.org/search', 'right url';
is $tx->req->headers->content_length, 17, 'right content length';
is $tx->req->body, 'query=mojolicious', 'right content';
like $tx->res->body, qr/Mojolicious/, 'right content';
is $tx->res->code, 200, 'right status';
is $tx->req->url, 'https://metacpan.org/search', 'right url';
is $tx->req->headers->content_length, 13, 'right content length';
is $tx->req->body, 'q=mojolicious', 'right content';
like $tx->res->body, qr/Mojolicious/, 'right content';
is $tx->res->code, 200, 'right status';
ok $tx->keep_alive, 'connection will be kept alive';
$tx = $ua->post(
'http://search.cpan.org/search' => form => {query => 'mojolicious'});
$tx = $ua->post('https://metacpan.org/search' => form => {q => 'mojolicious'});
is $tx->req->method, 'POST', 'right method';
is $tx->req->url, 'http://search.cpan.org/search', 'right url';
is $tx->req->headers->content_length, 17, 'right content length';
is $tx->req->body, 'query=mojolicious', 'right content';
like $tx->res->body, qr/Mojolicious/, 'right content';
is $tx->res->code, 200, 'right status';
is $tx->req->url, 'https://metacpan.org/search', 'right url';
is $tx->req->headers->content_length, 13, 'right content length';
is $tx->req->body, 'q=mojolicious', 'right content';
like $tx->res->body, qr/Mojolicious/, 'right content';
is $tx->res->code, 200, 'right status';
ok $tx->kept_alive, 'connection was kept alive';

# Simple request with redirect
Expand Down

0 comments on commit 9aeb94f

Please sign in to comment.