Skip to content

Commit

Permalink
just use the event loop
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Feb 26, 2015
1 parent edd4313 commit 7894739
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions t/mojo/user_agent_tls.t
Expand Up @@ -64,6 +64,7 @@ $ua->ioloop->client(
} => sub {
my ($loop, $err, $stream) = @_;
$sock = $stream->steal_handle;
$stream->close;
$loop->stop;
}
);
Expand Down
17 changes: 11 additions & 6 deletions t/mojo/websocket.t
Expand Up @@ -3,7 +3,6 @@ use Mojo::Base -strict;
BEGIN { $ENV{MOJO_REACTOR} = 'Mojo::Reactor::Poll' }

use Test::More;
use IO::Socket::INET;
use Mojo::ByteStream 'b';
use Mojo::IOLoop;
use Mojo::Transaction::WebSocket;
Expand Down Expand Up @@ -171,13 +170,19 @@ is $code, 200, 'right status';
ok $body =~ /^(\d+)failed!$/ && $1 == 15, 'right content';

# Using an already prepared socket
my $tx = $ua->build_websocket_tx('ws://lalala/socket');
my $sock;
Mojo::IOLoop->client(
{address => '127.0.0.1', port => $ua->server->nb_url->port} => sub {
my ($loop, $err, $stream) = @_;
$sock = $stream->steal_handle;
$stream->close;
Mojo::IOLoop->stop;
}
);
Mojo::IOLoop->start;
my $tx = $ua->build_websocket_tx('ws://lalala/socket')->connection($sock);
my $finished;
$tx->on(finish => sub { $finished++ });
my $port = $ua->server->nb_url->port;
my $sock = IO::Socket::INET->new(PeerAddr => '127.0.0.1', PeerPort => $port);
$sock->blocking(0);
$tx->connection($sock);
$result = '';
my $early;
$ua->start(
Expand Down

0 comments on commit 7894739

Please sign in to comment.