--- t/01-Redis.t 2009/03/23 11:30:40 47 +++ t/01-Redis.t 2009/03/24 22:51:53 53 @@ -3,7 +3,8 @@ use warnings; use strict; -use Test::More tests => 102; +use Test::More tests => 106; +use Data::Dump qw/dump/; use lib 'lib'; @@ -15,12 +16,12 @@ ok( $o->ping, 'ping' ); + 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' ); @@ -31,7 +32,6 @@ 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' ); -diag $o->exists( 'test-undef' ); ok( $o->exists( 'test-undef' ), 'exists undef' ); $o->del('non-existant'); @@ -64,8 +64,8 @@ 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' ); @@ -77,7 +77,6 @@ is_deeply( [ $o->keys('key-*') ], [ @keys ], 'keys' ); ok( my $key = $o->randomkey, 'randomkey' ); -diag "key: $key"; ok( $o->rename( 'test-incrby', 'test-renamed' ), 'rename' ); ok( $o->exists( 'test-renamed' ), 'exists test-renamed' ); @@ -86,7 +85,7 @@ ok( $@, 'rename to existing key' ); ok( my $nr_keys = $o->dbsize, 'dbsize' ); -diag "dbsize: $nr_keys"; + diag "Commands operating on lists"; @@ -162,6 +161,7 @@ ok( $o->flushdb, 'flushdb' ); cmp_ok( $o->dbsize, '==', 0, 'empty' ); + diag "Sorting"; ok( $o->lpush( 'test-sort', $_ ), "put $_" ) foreach ( 1 .. 4 ); @@ -170,6 +170,20 @@ is_deeply( [ $o->sort( 'test-sort' ) ], [ 1,2,3,4 ], 'sort' ); is_deeply( [ $o->sort( 'test-sort DESC' ) ], [ 4,3,2,1 ], 'sort DESC' ); + +diag "Persistence control commands"; + +ok( $o->save, 'save' ); +ok( $o->bgsave, 'bgsave' ); +ok( $o->lastsave, 'lastsave' ); +#ok( $o->shutdown, 'shutdown' ); +diag "shutdown not tested"; + +diag "Remote server control commands"; + +ok( my $info = $o->info, 'info' ); +diag dump( $info ); + diag "Connection handling"; ok( $o->quit, 'quit' );