mirror of
http://github.com/valkey-io/valkey
synced 2024-11-22 00:52:38 +00:00
SMOVE test added
This commit is contained in:
parent
a4460ef43f
commit
0eeb2a4b8f
@ -19,7 +19,7 @@ array set ::redis::bulkarg {}
|
||||
|
||||
# Flag commands requiring last argument as a bulk write operation
|
||||
foreach redis_bulk_cmd {
|
||||
set setnx rpush lpush lset lrem sadd srem sismember echo getset
|
||||
set setnx rpush lpush lset lrem sadd srem sismember echo getset smove
|
||||
} {
|
||||
set ::redis::bulkarg($redis_bulk_cmd) {}
|
||||
}
|
||||
|
@ -655,6 +655,41 @@ proc main {server port} {
|
||||
list [$r getset foo xyz] [$r get foo]
|
||||
} {bar xyz}
|
||||
|
||||
test {SMOVE basics} {
|
||||
$r sadd myset1 a
|
||||
$r sadd myset1 b
|
||||
$r sadd myset1 c
|
||||
$r sadd myset2 x
|
||||
$r sadd myset2 y
|
||||
$r sadd myset2 z
|
||||
$r smove myset1 myset2 a
|
||||
list [lsort [$r smembers myset2]] [lsort [$r smembers myset1]]
|
||||
} {{a x y z} {b c}}
|
||||
|
||||
test {SMOVE non existing key} {
|
||||
list [$r smove myset1 myset2 foo] [lsort [$r smembers myset2]] [lsort [$r smembers myset1]]
|
||||
} {0 {a x y z} {b c}}
|
||||
|
||||
test {SMOVE non existing src set} {
|
||||
list [$r smove noset myset2 foo] [lsort [$r smembers myset2]]
|
||||
} {0 {a x y z}}
|
||||
|
||||
test {SMOVE non existing dst set} {
|
||||
list [$r smove myset2 myset3 y] [lsort [$r smembers myset2]] [lsort [$r smembers myset3]]
|
||||
} {1 {a x z} y}
|
||||
|
||||
test {SMOVE wrong src key type} {
|
||||
$r set x 10
|
||||
catch {$r smove x myset2 foo} err
|
||||
format $err
|
||||
} {ERR*}
|
||||
|
||||
test {SMOVE wrong dst key type} {
|
||||
$r set x 10
|
||||
catch {$r smove myset2 x foo} err
|
||||
format $err
|
||||
} {ERR*}
|
||||
|
||||
# Leave the user with a clean DB before to exit
|
||||
test {FLUSHALL} {
|
||||
$r flushall
|
||||
|
Loading…
Reference in New Issue
Block a user