Skip to content

Commit

Permalink
test lazy sockets so we can bail out of tests without failing everything
Browse files Browse the repository at this point in the history
  • Loading branch information
friedo committed Dec 9, 2011
1 parent fe73394 commit 5abdc1b
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions t/RedisClientTest.pm
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,21 @@ sub server {
my $pw = $ENV{PERL_REDIS_TEST_PASSWORD} || undef;

my $client = eval {
Redis::Client->new( host => $host,
port => $port,
$pw ? ( password => $pw ) : ( ) );
my $c = Redis::Client->new( host => $host,
port => $port,
$pw ? ( password => $pw ) : ( ) );

# sockets are lazy, so test connection here
my $test = $c->echo( 'foobar' );
die 'something strange happened' if $test ne 'foobar';
$c;
};

return if $@;
if ( my $err = $@ ) {
warn $err;
return;
}

return $client;
}

Expand Down

0 comments on commit 5abdc1b

Please sign in to comment.