Promote all die's to confess(): more usefull information in case of errors
[perl-Redis.git] / t / 01-Redis.t
index 756135a..8157773 100755 (executable)
@@ -3,7 +3,8 @@
 use warnings;
 use strict;
 
-use Test::More tests => 110;
+use Test::More tests => 111;
+use Test::Exception;
 use Data::Dumper;
 
 use lib 'lib';
@@ -26,6 +27,10 @@ ok( ! $o->setnx( foo => 'bar' ), 'setnx foo => bar fails' );
 
 cmp_ok( $o->get( 'foo' ), 'eq', 'bar', 'get foo = bar' );
 
+ok( $o->set( foo => '' ), 'set foo => ""' );
+
+cmp_ok( $o->get( 'foo' ), 'eq', '', 'get foo = ""' );
+
 ok( $o->set( foo => 'baz' ), 'set foo => baz' );
 
 cmp_ok( $o->get( 'foo' ), 'eq', 'baz', 'get foo = baz' );
@@ -35,8 +40,6 @@ ok( $o->set( utf8 => $euro ), 'set utf8' );
 cmp_ok( $o->get( 'utf8' ), 'eq', $euro, 'get utf8' );
 
 ok( $o->set( 'test-undef' => 42 ), 'set test-undef' );
-ok( $o->set( 'test-undef' => undef ), 'set undef' );
-ok( ! defined $o->get( 'test-undef' ), 'get undef' );
 ok( $o->exists( 'test-undef' ), 'exists undef' );
 
 $o->del('non-existant');
@@ -173,7 +176,7 @@ ok( $o->lpush( 'test-sort', $_ ), "put $_" ) foreach ( 1 .. 4 );
 cmp_ok( $o->llen( 'test-sort' ), '==', 4, 'llen' );
 
 is_deeply( [ $o->sort( 'test-sort' )      ], [ 1,2,3,4 ], 'sort' );
-is_deeply( [ $o->sort( 'test-sort DESC' ) ], [ 4,3,2,1 ], 'sort DESC' );
+is_deeply( [ $o->sort( 'test-sort', 'DESC' ) ], [ 4,3,2,1 ], 'sort DESC' );
 
 
 diag "Persistence control commands";
@@ -193,3 +196,7 @@ diag Dumper( $info );
 diag "Connection handling";
 
 ok( $o->quit, 'quit' );
+
+throws_ok sub { Redis->new(server => '127.0.0.1:1') },
+  qr/Could not connect to Redis server at 127[.]0[.]0[.]1:1:/,
+  'Failed connection throws exception';