mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-23 08:38:27 -05:00
23325c135f
Summary of changes: 1. Rename `redisCommand->name` to `redisCommand->declared_name`, it is a const char * for native commands and SDS for module commands. 2. Store the [sub]command fullname in `redisCommand->fullname` (sds). 3. List subcommands in `ACL CAT` 4. List subcommands in `COMMAND LIST` 5. `moduleUnregisterCommands` now will also free the module subcommands. 6. RM_GetCurrentCommandName returns full command name Other changes: 1. Add `addReplyErrorArity` and `addReplyErrorExpireTime` 2. Remove `getFullCommandName` function that now is useless. 3. Some cleanups about `fullname` since now it is SDS. 4. Delete `populateSingleCommand` function from server.h that is useless. 5. Added tests to cover this change. 6. Add some module unload tests and fix the leaks 7. Make error messages uniform, make sure they always contain the full command name and that it's quoted. 7. Fixes some typos see the history in #9504, fixes #10124 Co-authored-by: Oran Agra <oran@redislabs.com> Co-authored-by: guybe7 <guy.benoish@redislabs.com>
71 lines
2.0 KiB
Tcl
71 lines
2.0 KiB
Tcl
set testmodule [file normalize tests/modules/list.so]
|
|
|
|
start_server {tags {"modules"}} {
|
|
r module load $testmodule
|
|
|
|
test {Module list set, get, insert, delete} {
|
|
r del k
|
|
r rpush k x
|
|
# insert, set, get
|
|
r list.insert k 0 foo
|
|
r list.insert k -1 bar
|
|
r list.set k 1 xyz
|
|
assert_equal {foo xyz bar} [r list.getall k]
|
|
assert_equal {foo} [r list.get k 0]
|
|
assert_equal {xyz} [r list.get k 1]
|
|
assert_equal {bar} [r list.get k 2]
|
|
assert_equal {bar} [r list.get k -1]
|
|
assert_equal {foo} [r list.get k -3]
|
|
assert_error {ERR index out*} {r list.get k -4}
|
|
assert_error {ERR index out*} {r list.get k 3}
|
|
# remove
|
|
assert_error {ERR index out*} {r list.delete k -4}
|
|
assert_error {ERR index out*} {r list.delete k 3}
|
|
r list.delete k 0
|
|
r list.delete k -1
|
|
assert_equal {xyz} [r list.getall k]
|
|
# removing the last element deletes the list
|
|
r list.delete k 0
|
|
assert_equal 0 [r exists k]
|
|
}
|
|
|
|
test {Module list iteration} {
|
|
r del k
|
|
r rpush k x y z
|
|
assert_equal {x y z} [r list.getall k]
|
|
assert_equal {z y x} [r list.getall k REVERSE]
|
|
}
|
|
|
|
test {Module list insert & delete} {
|
|
r del k
|
|
r rpush k x y z
|
|
r list.edit k ikikdi foo bar baz
|
|
r list.getall k
|
|
} {foo x bar y baz}
|
|
|
|
test {Module list insert & delete, neg index} {
|
|
r del k
|
|
r rpush k x y z
|
|
r list.edit k REVERSE ikikdi foo bar baz
|
|
r list.getall k
|
|
} {baz y bar z foo}
|
|
|
|
test {Module list set while iterating} {
|
|
r del k
|
|
r rpush k x y z
|
|
r list.edit k rkr foo bar
|
|
r list.getall k
|
|
} {foo y bar}
|
|
|
|
test {Module list set while iterating, neg index} {
|
|
r del k
|
|
r rpush k x y z
|
|
r list.edit k reverse rkr foo bar
|
|
r list.getall k
|
|
} {bar y foo}
|
|
|
|
test "Unload the module - list" {
|
|
assert_equal {OK} [r module unload list]
|
|
}
|
|
}
|