Permalink
Browse files

Make more use of Test::Deep to simplify tests

It was already one of our test_requires, so this has no additional cost for
users.
  • Loading branch information...
arc committed Jun 16, 2012
1 parent b3d5a71 commit d927b0daf1e28d088481e98b98b3fee4d01fd841
Showing with 3 additions and 12 deletions.
  1. +3 −12 t/04-pipeline.t
View
@@ -7,6 +7,7 @@ use Redis;
use lib 't/tlib';
use Test::SpawnRedisServer;
use Test::Exception;
+use Test::Deep;
my ($c, $srv) = redis();
END { $c->() if $c }
@@ -23,17 +24,7 @@ sub pipeline_ok {
}
$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);
+ cmp_deeply(\@responses, \@expected_responses, $desc);
}
pipeline_ok 'single-command pipeline', (
@@ -52,7 +43,7 @@ pipeline_ok 'keys in pipelined mode', (
);
pipeline_ok 'info in pipelined mode', (
- [info => [], {}], # any non-empty hashref
+ [info => [], code(sub { ref $_[0] eq 'HASH' && keys %{ $_[0] } })],
[info => ['oops'], undef, q[ERR wrong number of arguments for 'info' command]],
);

0 comments on commit d927b0d

Please sign in to comment.