Skip to content

Commit

Permalink
better parser error test
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Nov 19, 2012
1 parent 1974984 commit e8084fb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
4 changes: 2 additions & 2 deletions lib/Mojo/UserAgent.pm
Expand Up @@ -303,7 +303,7 @@ sub _error {
sub _finish {
my ($self, $tx, $cb, $close) = @_;

# Remove code
# Remove code from parser errors
my $res = $tx->res;
if (my $err = $res->error) { $res->error($err) }

Expand All @@ -320,7 +320,7 @@ sub _finish {
}

# Callback
$self->$cb($tx) if $cb;
$self->$cb($tx);
}

sub _handle {
Expand Down
19 changes: 11 additions & 8 deletions t/mojo/user_agent.t
Expand Up @@ -312,14 +312,17 @@ $tx = $ua->get('/timeout?timeout=5');
ok !$tx->success, 'not successful';
is $tx->error, 'Inactivity timeout', 'right error';

# GET /echo (with message size limit)
{
local $ENV{MOJO_MAX_MESSAGE_SIZE} = 12;
my $tx = $ua->get('/echo' => 'Hello World!');
ok !$tx->success, 'not successful';
is(($tx->error)[0], 'Maximum message size exceeded', 'right error');
is(($tx->error)[1], undef, 'no code');
}
# GET /echo (response exceeding message size limit)
$ua->once(
start => sub {
my ($ua, $tx) = @_;
$tx->res->max_message_size(12);
}
);
$tx = $ua->get('/echo' => 'Hello World!');
ok !$tx->success, 'not successful';
is(($tx->error)[0], 'Maximum message size exceeded', 'right error');
is(($tx->error)[1], undef, 'no code');

# GET /does_not_exist (404 response)
$tx = $ua->get('/does_not_exist');
Expand Down

0 comments on commit e8084fb

Please sign in to comment.