Skip to content
Browse files

Add tests for pipelined INFO and KEYS

Since they're the two pipeline-capable commands that have unusual return
values, it seems particularly valuable to test them.
  • Loading branch information...
1 parent dea5540 commit 89241f478e04e20c277b8c0b2d04e0ae5994c1b1 @arc committed Mar 8, 2012
Showing with 21 additions and 0 deletions.
  1. +21 −0 t/04-pipeline.t
View
21 t/04-pipeline.t
@@ -22,6 +22,17 @@ sub pipeline_ok {
$r->$method(@$args, sub { push @responses, [@_] });
}
$r->wait_all_responses;
+
+ # An expected response consisting of a hashref means that any non-empty
+ # hashref should be accepted. But reimplementing is_deeply() sounds like
+ # a pain, so fake it:
+ for my $i (0 .. $#expected_responses) {
+ $expected_responses[$i] = $responses[$i]
+ if ref $expected_responses[$i][0] eq 'HASH'
+ && ref $responses[$i][0] eq 'HASH'
+ && keys %{ $responses[$i][0] };
+ }
+
is_deeply(\@responses, \@expected_responses, $desc);
}
@@ -35,6 +46,16 @@ pipeline_ok 'pipeline with embedded error', (
[get => ['clunk'], 'eth'],
);
+pipeline_ok 'keys in pipelined mode', (
+ [keys => ['*'], [qw<foo clunk>]],
+ [keys => [], undef, q[ERR wrong number of arguments for 'keys' command]],
+);
+
+pipeline_ok 'info in pipelined mode', (
+ [info => [], {}], # any non-empty hashref
+ [info => ['oops'], undef, q[ERR wrong number of arguments for 'info' command]],
+);
+
pipeline_ok 'pipeline with multi-bulk reply', (
[hmset => [kapow => (a => 1, b => 2, c => 3)], 'OK'],
[hmget => [kapow => qw<c b a>], [3, 2, 1]],

0 comments on commit 89241f4

Please sign in to comment.
Something went wrong with that request. Please try again.