AnyEvent-Redis-RipeRedis
view release on metacpan or search on metacpan
t/04-commands.t view on Meta::CPAN
{ on_done => sub {
$cv->send();
}
}
);
}
);
is( $t_reply, 'ÐнаÑение', "GET; 'on_done' used; UTF-8 string" );
return;
}
sub t_get_utf8_string_mth2 {
my $redis = shift;
my $t_reply;
ev_loop(
sub {
my $cv = shift;
$redis->set( 'клÑÑ', 'ÐнаÑение' );
$redis->get( 'клÑÑ',
sub {
$t_reply = shift;
if ( @_ ) {
my $err_msg = shift;
diag( $err_msg );
}
}
);
$redis->del( 'клÑÑ',
sub {
shift;
if ( @_ ) {
my $err_msg = shift;
diag( $err_msg );
}
$cv->send();
}
);
}
);
is( $t_reply, 'ÐнаÑение', "GET; 'on_reply' used; UTF-8 string" );
return;
}
sub t_get_non_existent_mth1 {
my $redis = shift;
my $t_reply = 'not_undef';
ev_loop(
sub {
my $cv = shift;
$redis->get( 'non_existent',
{ on_done => sub {
$t_reply = shift;
$cv->send();
},
}
);
}
);
is( $t_reply, undef, "GET; 'on_done' used; non existent key" );
return;
}
sub t_get_non_existent_mth2 {
my $redis = shift;
my $t_reply = 'not_undef';
my $t_err_msg;
ev_loop(
sub {
my $cv = shift;
$redis->get( 'non_existent',
sub {
$t_reply = shift;
if ( @_ ) {
$t_err_msg = shift;
diag( $t_err_msg );
}
$cv->send();
}
);
}
);
ok( !defined $t_reply && !defined $t_err_msg,
"GET; 'on_reply' used; non existent key" );
return;
}
sub t_mbulk_reply_mth1 {
my $redis = shift;
my $t_reply;
ev_loop(
sub {
my $cv = shift;
for ( my $i = 1; $i <= 3; $i++ ) {
$redis->rpush( 'list', "element_$i" );
}
$redis->lrange( 'list', 0, -1,
{ on_done => sub {
$t_reply = shift;
},
}
);
$redis->del( 'list',
{ on_done => sub {
$cv->send();
}
}
);
}
);
is_deeply( $t_reply,
[ qw(
element_1
t/04-commands.t view on Meta::CPAN
}
sub t_mbulk_reply_empty_list_mth1 {
my $redis = shift;
my $t_reply;
ev_loop(
sub {
my $cv = shift;
$redis->lrange( 'non_existent', 0, -1,
{ on_done => sub {
$t_reply = shift;
$cv->send();
},
}
);
},
);
is_deeply( $t_reply, [], "LRANGE; 'on_done' used; empty list" );
return;
}
sub t_mbulk_reply_empty_list_mth2 {
my $redis = shift;
my $t_reply;
ev_loop(
sub {
my $cv = shift;
$redis->lrange( 'non_existent', 0, -1,
sub {
$t_reply = shift;
if ( @_ ) {
my $err_msg = shift;
diag( $err_msg );
}
$cv->send();
}
);
},
);
is_deeply( $t_reply, [], "LRANGE; 'on_reply' used; empty list" );
return;
}
sub t_mbulk_reply_undef_mth1 {
my $redis = shift;
my $t_reply = 'not_undef';
ev_loop(
sub {
my $cv = shift;
$redis->brpop( 'non_existent', '1',
{ on_done => sub {
$t_reply = shift;
$cv->send();
},
}
);
}
);
is( $t_reply, undef, "BRPOP; 'on_done' used; multi-bulk undef" );
return;
}
sub t_mbulk_reply_undef_mth2 {
my $redis = shift;
my $t_reply = 'not_undef';
my $t_err_msg;
ev_loop(
sub {
my $cv = shift;
$redis->brpop( 'non_existent', '1',
sub {
$t_reply = shift;
if ( @_ ) {
$t_err_msg = shift;
diag( $t_err_msg );
}
$cv->send();
}
);
}
);
ok( !defined $t_reply && !defined $t_err_msg,
"BRPOP; 'on_reply' used; multi-bulk undef" );
return;
}
sub t_nested_mbulk_reply_mth1 {
my $redis = shift;
my $t_reply;
ev_loop(
sub {
my $cv = shift;
for ( my $i = 1; $i <= 3; $i++ ) {
$redis->rpush( 'list', "element_$i" );
}
$redis->set( 'foo', "some\r\nstring" );
$redis->multi();
$redis->incr( 'bar' );
$redis->lrange( 'list', 0, -1 );
$redis->lrange( 'non_existent', 0, -1 );
$redis->get( 'foo' );
$redis->lrange( 'list', 0, -1 );
$redis->exec(
{ on_done => sub {
$t_reply = shift;
},
}
);
$redis->del( qw( foo list bar ),
{ on_done => sub {
$cv->send();
},
( run in 0.593 second using v1.01-cache-2.11-cpan-39bf76dae61 )