2
0

keyspecs.tcl 2.1 KB

1234567891011121314151617181920212223242526
  1. set testmodule [file normalize tests/modules/keyspecs.so]
  2. start_server {tags {"modules"}} {
  3. r module load $testmodule
  4. test "Module key specs: Legacy" {
  5. set reply [r command info kspec.legacy]
  6. assert_equal $reply {{kspec.legacy -1 {} 1 2 1 {} {{flags read begin_search {type index spec {index 1}} find_keys {type range spec {lastkey 0 keystep 1 limit 0}}} {flags write begin_search {type index spec {index 2}} find_keys {type range spec {lastkey 0 keystep 1 limit 0}}}} {}}}
  7. }
  8. test "Module key specs: Complex specs, case 1" {
  9. set reply [r command info kspec.complex1]
  10. assert_equal $reply {{kspec.complex1 -1 movablekeys 1 1 1 {} {{flags {} begin_search {type index spec {index 1}} find_keys {type range spec {lastkey 0 keystep 1 limit 0}}} {flags write begin_search {type keyword spec {keyword STORE startfrom 2}} find_keys {type range spec {lastkey 0 keystep 1 limit 0}}} {flags read begin_search {type keyword spec {keyword KEYS startfrom 2}} find_keys {type keynum spec {keynumidx 0 firstkey 1 keystep 1}}}} {}}}
  11. }
  12. test "Module key specs: Complex specs, case 2" {
  13. set reply [r command info kspec.complex2]
  14. assert_equal $reply {{kspec.complex2 -1 movablekeys 1 2 1 {} {{flags write begin_search {type keyword spec {keyword STORE startfrom 5}} find_keys {type range spec {lastkey 0 keystep 1 limit 0}}} {flags read begin_search {type index spec {index 1}} find_keys {type range spec {lastkey 0 keystep 1 limit 0}}} {flags read begin_search {type index spec {index 2}} find_keys {type range spec {lastkey 0 keystep 1 limit 0}}} {flags write begin_search {type index spec {index 3}} find_keys {type keynum spec {keynumidx 0 firstkey 1 keystep 1}}} {flags write begin_search {type keyword spec {keyword MOREKEYS startfrom 5}} find_keys {type range spec {lastkey -1 keystep 1 limit 0}}}} {}}}
  15. }
  16. test "Module command list filtering" {
  17. ;# Note: we piggyback this tcl file to test the general functionality of command list filtering
  18. set reply [r command list filterby module keyspecs]
  19. assert_equal [lsort $reply] {kspec.complex1 kspec.complex2 kspec.legacy}
  20. }
  21. }