Skip to content

Commit

Permalink
added a few message tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Sep 10, 2011
1 parent 9ac646c commit 05ae728
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/Mojo/Upload.pm
Expand Up @@ -5,9 +5,9 @@ use Carp 'croak';
use Mojo::Asset::File;
use Mojo::Headers;

has asset => sub { Mojo::Asset::File->new };
has headers => sub { Mojo::Headers->new };
has asset => sub { Mojo::Asset::File->new };
has [qw/filename name/];
has headers => sub { Mojo::Headers->new };

# "B-6
# You sunk my scrabbleship!
Expand Down
28 changes: 27 additions & 1 deletion t/mojo/message.t
Expand Up @@ -3,7 +3,7 @@ use Mojo::Base -strict;

use utf8;

use Test::More tests => 1122;
use Test::More tests => 1148;

use File::Spec;
use File::Temp;
Expand Down Expand Up @@ -2108,15 +2108,41 @@ is $req2->body, "Hello World!\n", 'right content';
$req = Mojo::Message::Request->new;
my $counter = 0;
$req->on_progress(sub { $counter++ });
is $counter, 0, 'right count';
is $req->content->is_parsing_body, undef, 'not parsing body';
is $req->is_done, undef, 'request is not done';
$req->parse('GET /foo/bar/baz.html?fo');
is $counter, 1, 'right count';
is $req->content->is_parsing_body, undef, 'not parsing body';
is $req->is_done, undef, 'request is not done';
$req->parse("o=13#23 HTTP/1.0\x0d\x0aContent");
is $counter, 2, 'right count';
is $req->content->is_parsing_body, undef, 'not parsing body';
is $req->is_done, undef, 'request is not done';
$req->parse('-Type: text/');
is $counter, 3, 'right count';
is $req->content->is_parsing_body, undef, 'not parsing body';
is $req->is_done, undef, 'request is not done';
$req->parse("plain\x0d\x0a");
is $counter, 4, 'right count';
is $req->content->is_parsing_body, undef, 'not parsing body';
is $req->is_done, undef, 'request is not done';
$req->parse('Cookie: $Version=1; foo=bar; $Path=/foobar; bar=baz; $Path=/t');
is $counter, 5, 'right count';
is $req->content->is_parsing_body, undef, 'not parsing body';
is $req->is_done, undef, 'request is not done';
$req->parse("est/23\x0d\x0a");
is $counter, 6, 'right count';
is $req->content->is_parsing_body, undef, 'not parsing body';
is $req->is_done, undef, 'request is not done';
$req->parse("Content-Length: 27\x0d\x0a\x0d\x0aHell");
is $counter, 7, 'right count';
is $req->content->is_parsing_body, 1, 'is parsing body';
is $req->is_done, undef, 'request is not done';
$req->parse("o World!\n1234\nlalalala\n");
is $counter, 8, 'right count';
is $req->content->is_parsing_body, undef, 'is parsing body';
is $req->is_done, 1, 'request is done';
ok $req->is_done, 'request is done';
is $req->method, 'GET', 'right method';
is $req->version, '1.0', 'right version';
Expand Down

0 comments on commit 05ae728

Please sign in to comment.