hash.tcl 1.0 KB

1234567891011121314151617181920212223
  1. set testmodule [file normalize tests/modules/hash.so]
  2. start_server {tags {"modules"}} {
  3. r module load $testmodule
  4. test {Module hash set} {
  5. r set k mystring
  6. assert_error "WRONGTYPE*" {r hash.set k "" hello world}
  7. r del k
  8. # "" = count updates and deletes of existing fields only
  9. assert_equal 0 [r hash.set k "" squirrel yes]
  10. # "a" = COUNT_ALL = count inserted, modified and deleted fields
  11. assert_equal 2 [r hash.set k "a" banana no sushi whynot]
  12. # "n" = NX = only add fields not already existing in the hash
  13. # "x" = XX = only replace the value for existing fields
  14. assert_equal 0 [r hash.set k "n" squirrel hoho what nothing]
  15. assert_equal 1 [r hash.set k "na" squirrel hoho something nice]
  16. assert_equal 0 [r hash.set k "xa" new stuff not inserted]
  17. assert_equal 1 [r hash.set k "x" squirrel ofcourse]
  18. assert_equal 1 [r hash.set k "" sushi :delete: none :delete:]
  19. r hgetall k
  20. } {squirrel ofcourse banana no what nothing something nice}
  21. }