X-Git-Url: https://git.saurik.com/redis.git/blobdiff_plain/ab72b4833d2054231437acccec36f32f07290075..890a2ed989274cb09b5cde1def3935e110ec3cb9:/tests/unit/type/hash.tcl diff --git a/tests/unit/type/hash.tcl b/tests/unit/type/hash.tcl index 3fdc05e0..9b043d3f 100644 --- a/tests/unit/type/hash.tcl +++ b/tests/unit/type/hash.tcl @@ -1,4 +1,4 @@ -start_server default.conf {} { +start_server {tags {"hash"}} { test {HSET/HLEN - Small hash creation} { array set smallhash {} for {set i 0} {$i < 8} {incr i} { @@ -15,8 +15,8 @@ start_server default.conf {} { } {8} test {Is the small hash encoded with a zipmap?} { - r debug object smallhash - } {*zipmap*} + assert_encoding zipmap smallhash + } test {HSET/HLEN - Big hash creation} { array set bighash {} @@ -34,8 +34,8 @@ start_server default.conf {} { } {1024} test {Is the big hash encoded with a zipmap?} { - r debug object bighash - } {*hashtable*} + assert_encoding hashtable bighash + } test {HGET against the small hash} { set err {} @@ -140,6 +140,11 @@ start_server default.conf {} { set _ $rv } {{{} {}} {{} {}} {{} {}}} + test {HMGET against wrong type} { + r set wrongtype somevalue + assert_error "*wrong*" {r hmget wrongtype field1 field2} + } + test {HMGET - small hash} { set keys {} set vals {} @@ -221,6 +226,15 @@ start_server default.conf {} { set _ $rv } {0 0 1 0 {} 1 0 {}} + test {HDEL - more than a single value} { + set rv {} + r del myhash + r hmset myhash a 1 b 2 c 3 + assert_equal 0 [r hdel myhash x y] + assert_equal 2 [r hdel myhash a c f] + r hgetall myhash + } {b 2} + test {HEXISTS} { set rv {} set k [lindex [array names smallhash *] 0] @@ -286,4 +300,10 @@ start_server default.conf {} { lappend rv [string match "ERR*not an integer*" $smallerr] lappend rv [string match "ERR*not an integer*" $bigerr] } {1 1} + + test {Hash zipmap regression test for large keys} { + r hset hash kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk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