#!/usr/bin/env perl
my
$r1
= Test::Mock::Redis->new(
server
=>
'1.1.1.1:1111'
);
like exception {
$r1
->
select
(19) },
qr/\QYou called select(19), but max allowed is 15/
;
Test::Mock::Redis->
import
(
num_databases
=> 20);
my
$r2
= Test::Mock::Redis->new(
server
=>
'2.2.2.2:2222'
);
$r2
->set(
'key-in-default-db-0'
,
'foobar'
);
is exception {
$r2
->
select
(19) },
undef
;
$r2
->set(
'key1'
,
'foobar'
);
$r2
->set(
'key2'
,
'foobar'
);
cmp_deeply( [
$r2
->
keys
(
'*'
) ], bag(
'key1'
,
'key2'
));
Test::Mock::Redis::change_num_databases(30);
my
$r3
= Test::Mock::Redis->new(
server
=>
'3.3.3.3:3333'
);
$r3
->set(
'key-in-default-db-0'
,
'foobar'
);
is exception {
$r3
->
select
(29) },
undef
;
$r3
->set(
'key1'
,
'foobar'
);
$r3
->set(
'key2'
,
'foobar'
);
cmp_deeply( [
$r3
->
keys
(
'*'
) ], bag(
'key1'
,
'key2'
));
done_testing();