diff options
Diffstat (limited to 'examples/redis-unstable/tests/unit/moduleapi/subcommands.tcl')
| -rw-r--r-- | examples/redis-unstable/tests/unit/moduleapi/subcommands.tcl | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/examples/redis-unstable/tests/unit/moduleapi/subcommands.tcl b/examples/redis-unstable/tests/unit/moduleapi/subcommands.tcl deleted file mode 100644 index f3734a8..0000000 --- a/examples/redis-unstable/tests/unit/moduleapi/subcommands.tcl +++ /dev/null | |||
| @@ -1,61 +0,0 @@ | |||
| 1 | set testmodule [file normalize tests/modules/subcommands.so] | ||
| 2 | |||
| 3 | start_server {tags {"modules external:skip"}} { | ||
| 4 | r module load $testmodule | ||
| 5 | |||
| 6 | test "Module subcommands via COMMAND" { | ||
| 7 | # Verify that module subcommands are displayed correctly in COMMAND | ||
| 8 | set command_reply [r command info subcommands.bitarray] | ||
| 9 | set first_cmd [lindex $command_reply 0] | ||
| 10 | set subcmds_in_command [lsort [lindex $first_cmd 9]] | ||
| 11 | assert_equal [lindex $subcmds_in_command 0] {subcommands.bitarray|get -2 module 1 1 1 {} {} {{flags {RO access} begin_search {type index spec {index 1}} find_keys {type range spec {lastkey 0 keystep 1 limit 0}}}} {}} | ||
| 12 | assert_equal [lindex $subcmds_in_command 1] {subcommands.bitarray|set -2 module 1 1 1 {} {} {{flags {RW update} begin_search {type index spec {index 1}} find_keys {type range spec {lastkey 0 keystep 1 limit 0}}}} {}} | ||
| 13 | |||
| 14 | # Verify that module subcommands are displayed correctly in COMMAND DOCS | ||
| 15 | set docs_reply [r command docs subcommands.bitarray] | ||
| 16 | set docs [dict create {*}[lindex $docs_reply 1]] | ||
| 17 | set subcmds_in_cmd_docs [dict create {*}[dict get $docs subcommands]] | ||
| 18 | assert_equal [dict get $subcmds_in_cmd_docs "subcommands.bitarray|get"] {group module module subcommands} | ||
| 19 | assert_equal [dict get $subcmds_in_cmd_docs "subcommands.bitarray|set"] {group module module subcommands} | ||
| 20 | } | ||
| 21 | |||
| 22 | test "Module pure-container command fails on arity error" { | ||
| 23 | catch {r subcommands.bitarray} e | ||
| 24 | assert_match {*wrong number of arguments for 'subcommands.bitarray' command} $e | ||
| 25 | |||
| 26 | # Subcommands can be called | ||
| 27 | assert_equal [r subcommands.bitarray get k1] {OK} | ||
| 28 | |||
| 29 | # Subcommand arity error | ||
| 30 | catch {r subcommands.bitarray get k1 8 90} e | ||
| 31 | assert_match {*wrong number of arguments for 'subcommands.bitarray|get' command} $e | ||
| 32 | } | ||
| 33 | |||
| 34 | test "Module get current command fullname" { | ||
| 35 | assert_equal [r subcommands.parent_get_fullname] {subcommands.parent_get_fullname} | ||
| 36 | } | ||
| 37 | |||
| 38 | test "Module get current subcommand fullname" { | ||
| 39 | assert_equal [r subcommands.sub get_fullname] {subcommands.sub|get_fullname} | ||
| 40 | } | ||
| 41 | |||
| 42 | test "COMMAND LIST FILTERBY MODULE" { | ||
| 43 | assert_equal {} [r command list filterby module non_existing] | ||
| 44 | |||
| 45 | set commands [r command list filterby module subcommands] | ||
| 46 | assert_not_equal [lsearch $commands "subcommands.bitarray"] -1 | ||
| 47 | assert_not_equal [lsearch $commands "subcommands.bitarray|set"] -1 | ||
| 48 | assert_not_equal [lsearch $commands "subcommands.parent_get_fullname"] -1 | ||
| 49 | assert_not_equal [lsearch $commands "subcommands.sub|get_fullname"] -1 | ||
| 50 | |||
| 51 | assert_equal [lsearch $commands "set"] -1 | ||
| 52 | } | ||
| 53 | |||
| 54 | test "Internal container command without subcommand returns missing subcommand error" { | ||
| 55 | assert_error {*missing subcommand*} {r subcommands.internal_container} | ||
| 56 | } | ||
| 57 | |||
| 58 | test "Unload the module - subcommands" { | ||
| 59 | assert_equal {OK} [r module unload subcommands] | ||
| 60 | } | ||
| 61 | } | ||
