--- t/01-Redis.t 2009/03/21 23:39:53 16 +++ t/01-Redis.t 2009/03/22 13:37:49 26 @@ -3,7 +3,7 @@ use warnings; use strict; -use Test::More tests => 52; +use Test::More tests => 69; use lib 'lib'; @@ -75,4 +75,34 @@ eval { $o->rename( 'test-decrby', 'test-renamed', 1 ) }; ok( $@, 'rename to existing key' ); +ok( my $nr_keys = $o->dbsize, 'dbsize' ); +diag "dbsize: $nr_keys"; + +diag "Commands operating on lists"; + +my $list = 'test-list'; + +$o->del($list) && diag "cleanup $list from last run"; + +ok( $o->rpush( $list => "r$_" ), 'rpush' ) foreach ( 1 .. 3 ); + +ok( $o->lpush( $list => "l$_" ), 'lpush' ) foreach ( 1 .. 2 ); + +cmp_ok( $o->type($list), 'eq', 'list', 'type' ); +cmp_ok( $o->llen($list), '==', 5, 'llen' ); + +is_deeply( [ $o->lrange( $list, 0, 1 ) ], [ 'l2', 'l1' ], 'lrange' ); + +ok( $o->ltrim( $list, 1, 2 ), 'ltrim' ); +cmp_ok( $o->llen($list), '==', 2, 'llen after ltrim' ); + +cmp_ok( $o->lindex( $list, 0 ), 'eq', 'l1', 'lindex' ); +cmp_ok( $o->lindex( $list, 1 ), 'eq', 'r1', 'lindex' ); + +ok( $o->lset( $list, 0, 'foo' ), 'lset' ); +cmp_ok( $o->lindex( $list, 0 ), 'eq', 'foo', 'verified' ); + +ok( $o->lrem( $list, 1, 'foo' ), 'lrem' ); +cmp_ok( $o->llen( $list ), '==', 1, 'llen after lrem' ); + ok( $o->quit, 'quit' );