diff options
author | Oran Agra <oran@redislabs.com> | 2022-02-28 15:35:46 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-28 15:35:46 +0200 |
commit | d2b5a579dd8b785690aa7714df8776ffc452d242 (patch) | |
tree | 1c54c71bae68eaa44efbf89020d75399a88dee40 /tests/unit/moduleapi/cmdintrospection.tcl | |
parent | d5915a167f696644e210ee85e549c7ceb41b5791 (diff) | |
parent | 10dc57ab226155bbdbfb0b0d914e681aa346d7de (diff) | |
download | redis-7.0-rc2.tar.gz |
Merge pull request #10355 from oranagra/release-7.0-rc27.0-rc2
Release 7.0 RC2
Diffstat (limited to 'tests/unit/moduleapi/cmdintrospection.tcl')
-rw-r--r-- | tests/unit/moduleapi/cmdintrospection.tcl | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/unit/moduleapi/cmdintrospection.tcl b/tests/unit/moduleapi/cmdintrospection.tcl new file mode 100644 index 000000000..375b3e406 --- /dev/null +++ b/tests/unit/moduleapi/cmdintrospection.tcl @@ -0,0 +1,42 @@ +set testmodule [file normalize tests/modules/cmdintrospection.so] + +start_server {tags {"modules"}} { + r module load $testmodule + + # cmdintrospection.xadd mimics XADD with regards to how + # what COMMAND exposes. There are two differences: + # + # 1. cmdintrospection.xadd (and all module commands) do not have ACL categories + # 2. cmdintrospection.xadd's `group` is "module" + # + # This tests verify that, apart from the above differences, the output of + # COMMAND INFO and COMMAND DOCS are identical for the two commands. + test "Module command introspection via COMMAND INFO" { + set redis_reply [lindex [r command info xadd] 0] + set module_reply [lindex [r command info cmdintrospection.xadd] 0] + for {set i 1} {$i < [llength $redis_reply]} {incr i} { + if {$i == 2} { + # Remove the "module" flag + set mylist [lindex $module_reply $i] + set idx [lsearch $mylist "module"] + set mylist [lreplace $mylist $idx $idx] + lset module_reply $i $mylist + } + if {$i == 6} { + # Skip ACL categories + continue + } + assert_equal [lindex $redis_reply $i] [lindex $module_reply $i] + } + } + + test "Module command introspection via COMMAND DOCS" { + set redis_reply [dict create {*}[lindex [r command docs xadd] 1]] + set module_reply [dict create {*}[lindex [r command docs cmdintrospection.xadd] 1]] + # Compare the maps. We need to pop "group" first. + dict unset redis_reply group + dict unset module_reply group + + assert_equal $redis_reply $module_reply + } +} |