test that info returns HASH
[perl-Redis.git] / t / 01-Redis.t
index 211f743..4dc7a85 100755 (executable)
@@ -3,7 +3,7 @@
 use warnings;
 use strict;
 
-use Test::More tests => 106;
+use Test::More tests => 107;
 use Data::Dump qw/dump/;
 
 use lib 'lib';
@@ -21,8 +21,7 @@ diag "Commands operating on string values";
 
 ok( $o->set( foo => 'bar' ), 'set foo => bar' );
 
-eval { $o->set( foo => 'bar', 1 ) };
-ok( $@, 'set foo => bar new again failed' );
+ok( ! $o->setnx( foo => 'bar' ), 'setnx foo => bar fails' );
 
 cmp_ok( $o->get( 'foo' ), 'eq', 'bar', 'get foo = bar' );
 
@@ -50,14 +49,14 @@ is_deeply( [ $o->mget( 'foo', 'key-next', 'key-left' ) ], [ 'baz', 0, 3 ], 'mget
 
 my @keys;
 
-foreach ( 0 .. $key_next ) {
-       my $key = 'key-' . $_;
+foreach my $id ( 0 .. $key_next ) {
+       my $key = 'key-' . $id;
        push @keys, $key;
-       ok(     $o->set( $key => $_ ),           "set $key" );
+       ok(     $o->set( $key => $id ),           "set $key" );
        ok(  $o->exists( $key       ),           "exists $key" );
-       cmp_ok( $o->get( $key       ), 'eq', $_, "get $key" );
-       cmp_ok( $o->incr( 'key-next' ), '==', $_ + 1, 'incr' );
-       cmp_ok( $o->decr( 'key-left' ), '==', $key_next - $_ - 1, 'decr' );
+       cmp_ok( $o->get( $key       ), 'eq', $id, "get $key" );
+       cmp_ok( $o->incr( 'key-next' ), '==', $id + 1, 'incr' );
+       cmp_ok( $o->decr( 'key-left' ), '==', $key_next - $id - 1, 'decr' );
 }
 
 cmp_ok( $o->get( 'key-next' ), '==', $key_next + 1, 'key-next' );
@@ -65,8 +64,8 @@ cmp_ok( $o->get( 'key-next' ), '==', $key_next + 1, 'key-next' );
 ok( $o->set('test-incrby', 0), 'test-incrby' );
 ok( $o->set('test-decrby', 0), 'test-decry' );
 foreach ( 1 .. 3 ) {
-       cmp_ok( $o->incr('test-incrby', 3), '==', $_ * 3, 'incrby 3' );
-       cmp_ok( $o->decr('test-decrby', 7), '==', -( $_ * 7 ), 'decrby 7' );
+       cmp_ok( $o->incrby('test-incrby', 3), '==', $_ * 3, 'incrby 3' );
+       cmp_ok( $o->decrby('test-decrby', 7), '==', -( $_ * 7 ), 'decrby 7' );
 }
 
 ok( $o->del( $_ ), "del $_" ) foreach map { "key-$_" } ( 'next', 'left' );
@@ -139,7 +138,7 @@ cmp_ok( $o->scard( $set ), '==', 0, 'scard' );
 $o->sadd( 'test-set1', $_ ) foreach ( 'foo', 'bar', 'baz' );
 $o->sadd( 'test-set2', $_ ) foreach ( 'foo', 'baz', 'xxx' );
 
-my $inter = [ 'baz', 'foo' ];
+my $inter = [ 'foo', 'baz' ];
 
 is_deeply( [ $o->sinter( 'test-set1', 'test-set2' ) ], $inter, 'siter' );
 
@@ -183,6 +182,7 @@ diag "shutdown not tested";
 diag "Remote server control commands";
 
 ok( my $info = $o->info, 'info' );
+isa_ok( $info, 'HASH' );
 diag dump( $info );
 
 diag "Connection handling";