3 |
use warnings; |
use warnings; |
4 |
use strict; |
use strict; |
5 |
|
|
6 |
use Test::More tests => 95; |
use Test::More tests => 106; |
7 |
|
use Data::Dump qw/dump/; |
8 |
|
|
9 |
use lib 'lib'; |
use lib 'lib'; |
10 |
|
|
16 |
|
|
17 |
ok( $o->ping, 'ping' ); |
ok( $o->ping, 'ping' ); |
18 |
|
|
19 |
|
|
20 |
diag "Commands operating on string values"; |
diag "Commands operating on string values"; |
21 |
|
|
22 |
ok( $o->set( foo => 'bar' ), 'set foo => bar' ); |
ok( $o->set( foo => 'bar' ), 'set foo => bar' ); |
33 |
ok( $o->set( 'test-undef' => 42 ), 'set test-undef' ); |
ok( $o->set( 'test-undef' => 42 ), 'set test-undef' ); |
34 |
ok( $o->set( 'test-undef' => undef ), 'set undef' ); |
ok( $o->set( 'test-undef' => undef ), 'set undef' ); |
35 |
ok( ! defined $o->get( 'test-undef' ), 'get undef' ); |
ok( ! defined $o->get( 'test-undef' ), 'get undef' ); |
|
diag $o->exists( 'test-undef' ); |
|
36 |
ok( $o->exists( 'test-undef' ), 'exists undef' ); |
ok( $o->exists( 'test-undef' ), 'exists undef' ); |
37 |
|
|
38 |
$o->del('non-existant'); |
$o->del('non-existant'); |
78 |
is_deeply( [ $o->keys('key-*') ], [ @keys ], 'keys' ); |
is_deeply( [ $o->keys('key-*') ], [ @keys ], 'keys' ); |
79 |
|
|
80 |
ok( my $key = $o->randomkey, 'randomkey' ); |
ok( my $key = $o->randomkey, 'randomkey' ); |
|
diag "key: $key"; |
|
81 |
|
|
82 |
ok( $o->rename( 'test-incrby', 'test-renamed' ), 'rename' ); |
ok( $o->rename( 'test-incrby', 'test-renamed' ), 'rename' ); |
83 |
ok( $o->exists( 'test-renamed' ), 'exists test-renamed' ); |
ok( $o->exists( 'test-renamed' ), 'exists test-renamed' ); |
86 |
ok( $@, 'rename to existing key' ); |
ok( $@, 'rename to existing key' ); |
87 |
|
|
88 |
ok( my $nr_keys = $o->dbsize, 'dbsize' ); |
ok( my $nr_keys = $o->dbsize, 'dbsize' ); |
89 |
diag "dbsize: $nr_keys"; |
|
90 |
|
|
91 |
diag "Commands operating on lists"; |
diag "Commands operating on lists"; |
92 |
|
|
162 |
ok( $o->flushdb, 'flushdb' ); |
ok( $o->flushdb, 'flushdb' ); |
163 |
cmp_ok( $o->dbsize, '==', 0, 'empty' ); |
cmp_ok( $o->dbsize, '==', 0, 'empty' ); |
164 |
|
|
165 |
|
|
166 |
|
diag "Sorting"; |
167 |
|
|
168 |
|
ok( $o->lpush( 'test-sort', $_ ), "put $_" ) foreach ( 1 .. 4 ); |
169 |
|
cmp_ok( $o->llen( 'test-sort' ), '==', 4, 'llen' ); |
170 |
|
|
171 |
|
is_deeply( [ $o->sort( 'test-sort' ) ], [ 1,2,3,4 ], 'sort' ); |
172 |
|
is_deeply( [ $o->sort( 'test-sort DESC' ) ], [ 4,3,2,1 ], 'sort DESC' ); |
173 |
|
|
174 |
|
|
175 |
|
diag "Persistence control commands"; |
176 |
|
|
177 |
|
ok( $o->save, 'save' ); |
178 |
|
ok( $o->bgsave, 'bgsave' ); |
179 |
|
ok( $o->lastsave, 'lastsave' ); |
180 |
|
#ok( $o->shutdown, 'shutdown' ); |
181 |
|
diag "shutdown not tested"; |
182 |
|
|
183 |
|
diag "Remote server control commands"; |
184 |
|
|
185 |
|
ok( my $info = $o->info, 'info' ); |
186 |
|
diag dump( $info ); |
187 |
|
|
188 |
diag "Connection handling"; |
diag "Connection handling"; |
189 |
|
|
190 |
ok( $o->quit, 'quit' ); |
ok( $o->quit, 'quit' ); |