Permalink
Browse files

Merge pull request #23 from arc/support-2-6

Support Redis 2.6
  • Loading branch information...
2 parents b3d5a71 + 2327f17 commit 03e41d719fbd60664fbdb92390f57d8eec00e165 @melo melo committed Jun 18, 2012
Showing with 15 additions and 18 deletions.
  1. +1 −0 Changes
  2. +1 −1 lib/Redis.pm
  3. +7 −3 t/01-basic.t
  4. +6 −14 t/04-pipeline.t
View
1 Changes
@@ -2,6 +2,7 @@ Revision history for Redis
{{$NEXT}}
* Added automatic authentication after connection establishment
+ * Support Redis 2.6: Aaron Crane <arc@cpan.org>
1.951 2012-03-13T10:17:09Z
* Remove Tie::StdHash from our dependencies list, its part of core
View
2 lib/Redis.pm
@@ -221,7 +221,7 @@ sub info {
my $custom_decode = sub {
my ($reply) = @_;
return $reply if !defined $reply || ref $reply;
- return { map { split(/:/, $_, 2) } split(/\r\n/, $reply) };
+ return { map { split(/:/, $_, 2) } grep { /^[^#]/ } split(/\r\n/, $reply) };
};
my $cb = @_ && ref $_[-1] eq 'CODE' ? pop : undef;
View
10 t/01-basic.t
@@ -80,7 +80,7 @@ ok(!$o->del('non-existing'), 'del non-existing');
cmp_ok($o->type('foo'), 'eq', 'string', 'type');
is($o->keys('key-*'), $key_next + 1, 'key-*');
-is_deeply([$o->keys('key-*')], [@keys], 'keys');
+is_deeply([sort $o->keys('key-*')], [sort @keys], 'keys');
ok(my $key = $o->randomkey, 'randomkey');
@@ -168,7 +168,7 @@ ok($o->sdiffstore(qw( test-set-diff test-set1 test-set2 )), 'sdiffstore');
is($o->scard('test-set-diff'), 1, 'cardinality of diff');
my @union = sort qw( foo bar baz xxx );
-is_deeply([$o->sunion(qw( test-set1 test-set2 ))], \@union, 'sunion');
+is_deeply([sort $o->sunion(qw( test-set1 test-set2 ))], \@union, 'sunion');
ok($o->sunionstore(qw( test-set-union test-set1 test-set2 )), 'sunionstore');
is($o->scard('test-set-union'), scalar(@union), 'cardinality of union');
@@ -331,7 +331,11 @@ ok($o->lastsave, 'lastsave');
## Remote server control commands
ok(my $info = $o->info, 'info');
-isa_ok($info, 'HASH');
+isa_ok($info, 'HASH', '... yields a hash');
+ok(keys %$info, '... nonempty');
+unlike(join("\n", keys %$info), qr/#/, '... with no comments in the keys');
+unlike(join("\n", keys %$info), qr/\n\n|\A\n|\n\z/,
+ '... with no blank lines in the keys');
## Connection handling
View
20 t/04-pipeline.t
@@ -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', (
@@ -47,13 +38,14 @@ pipeline_ok 'pipeline with embedded error', (
);
pipeline_ok 'keys in pipelined mode', (
- [keys => ['*'], [qw<foo clunk>]],
+ [keys => ['*'], bag(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]],
+ [info => [], code(sub { ref $_[0] eq 'HASH' && keys %{ $_[0] } })],
+ [info => [qw<oops oops>], undef,
+ re(qr/^ERR (?:syntax error|wrong number of arguments for 'info' command)$/)],
);
pipeline_ok 'pipeline with multi-bulk reply', (

0 comments on commit 03e41d7

Please sign in to comment.