Skip to content

Commit

Permalink
a few more arrows
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Aug 11, 2012
1 parent 70cd9bb commit 6438114
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 22 deletions.
16 changes: 8 additions & 8 deletions t/mojo/transactor.t
Expand Up @@ -38,38 +38,38 @@ is $tx->req->headers->expect, 'nothing', 'right "Expect" value';
is $tx->req->body, 'test', 'right content';

# DELETE with content
$tx = $t->tx(DELETE => 'https://mojolicio.us', 'test');
$tx = $t->tx(DELETE => 'https://mojolicio.us' => 'test');
is $tx->req->url->to_abs, 'https://mojolicio.us', 'right URL';
is $tx->req->method, 'DELETE', 'right method';
is $tx->req->headers->expect, undef, 'no "Expect" value';
is $tx->req->body, 'test', 'right content';

# Simple JSON POST
$tx = $t->json('http://kraih.com/foo', => {test => 123});
$tx = $t->json('http://kraih.com/foo' => {test => 123});
is $tx->req->url->to_abs, 'http://kraih.com/foo', 'right URL';
is $tx->req->method, 'POST', 'right method';
is $tx->req->headers->content_type, 'application/json',
'right "Content-Type" value';
is_deeply $tx->req->json, {test => 123} => 'right content';
$tx = $t->json('http://kraih.com/foo', => [1, 2, 3]);
is_deeply $tx->req->json, {test => 123}, 'right content';
$tx = $t->json('http://kraih.com/foo' => [1, 2, 3]);
is $tx->req->url->to_abs, 'http://kraih.com/foo', 'right URL';
is $tx->req->method, 'POST', 'right method';
is $tx->req->headers->content_type, 'application/json',
'right "Content-Type" value';
is_deeply $tx->req->json, [1, 2, 3], 'right content';

# JSON POST with headers
$tx = $t->json('http://kraih.com/foo', => {test => 123} => {DNT => 1});
$tx = $t->json('http://kraih.com/foo' => {test => 123} => {DNT => 1});
is $tx->req->url->to_abs, 'http://kraih.com/foo', 'right URL';
is $tx->req->method, 'POST', 'right method';
is $tx->req->headers->dnt, 1, 'right "DNT" value';
is $tx->req->headers->content_type, 'application/json',
'right "Content-Type" value';
is_deeply $tx->req->json, {test => 123} => 'right content';
is_deeply $tx->req->json, {test => 123}, 'right content';

# JSON POST with custom content type
$tx = $t->json(
'http://kraih.com/foo', => [1, 2, 3],
'http://kraih.com/foo' => [1, 2, 3],
{DNT => 1, 'content-type' => 'application/something'}
);
is $tx->req->url->to_abs, 'http://kraih.com/foo', 'right URL';
Expand All @@ -96,7 +96,7 @@ is $tx->req->headers->content_type, 'application/x-www-form-urlencoded',
is $tx->req->body, 'test=1&test=2&test=3', 'right content';

# UTF-8 form
$tx = $t->form('http://kraih.com/foo', 'UTF-8' => {test => 123});
$tx = $t->form('http://kraih.com/foo' => 'UTF-8' => {test => 123});
is $tx->req->url->to_abs, 'http://kraih.com/foo', 'right URL';
is $tx->req->method, 'POST', 'right method';
is $tx->req->headers->content_type, 'application/x-www-form-urlencoded',
Expand Down
12 changes: 4 additions & 8 deletions t/mojo/user_agent_online.t
Expand Up @@ -103,8 +103,7 @@ $ua->get('http://mojolicio.us' => sub { Mojo::IOLoop->singleton->stop });
Mojo::IOLoop->singleton->start;
my $kept_alive;
$ua->get(
'http://mojolicio.us',
sub {
'http://mojolicio.us' => sub {
my $tx = pop;
Mojo::IOLoop->singleton->stop;
$kept_alive = $tx->kept_alive;
Expand All @@ -116,18 +115,15 @@ ok $kept_alive, 'connection was kept alive';
# Nested keep alive
my @kept_alive;
$ua->get(
'http://mojolicio.us',
sub {
'http://mojolicio.us' => sub {
my ($self, $tx) = @_;
push @kept_alive, $tx->kept_alive;
$self->get(
'http://mojolicio.us',
sub {
'http://mojolicio.us' => sub {
my ($self, $tx) = @_;
push @kept_alive, $tx->kept_alive;
$self->get(
'http://mojolicio.us',
sub {
'http://mojolicio.us' => sub {
my ($self, $tx) = @_;
push @kept_alive, $tx->kept_alive;
Mojo::IOLoop->singleton->stop;
Expand Down
6 changes: 2 additions & 4 deletions t/mojo/websocket.t
Expand Up @@ -61,8 +61,7 @@ get '/something/else' => sub {
websocket '/socket' => sub {
my $self = shift;
$self->send(
$self->req->headers->host,
sub {
$self->req->headers->host => sub {
my $self = shift;
$self->send(Mojo::IOLoop->stream($self->tx->connection)->timeout);
$self->finish;
Expand Down Expand Up @@ -372,8 +371,7 @@ $ua->websocket(
);
$client = 1;
$tx->send(
'hi!',
sub {
'hi!' => sub {
shift->send('there!');
$drain
+= @{Mojo::IOLoop->stream($tx->connection)->subscribers('drain')};
Expand Down
3 changes: 1 addition & 2 deletions t/mojolicious/external/myapp.pl
Expand Up @@ -32,8 +32,7 @@
# GET /stream
get '/stream' => sub {
shift->write_chunk(
'he',
sub {
'he' => sub {
shift->write_chunk('ll' => sub { shift->finish('o!') });
}
);
Expand Down

0 comments on commit 6438114

Please sign in to comment.