From 5dc631d880eea750d394651d70822ffabe13caae Mon Sep 17 00:00:00 2001 From: Wen Hui Date: Sun, 17 Dec 2023 07:02:53 -0500 Subject: [PATCH] Add missing test cases for hash commands (#12851) We dont have test for hgetall against key doesnot exist so added the test in test suite and along with this, added wrong type cases for other missing commands. --- tests/unit/type/hash.tcl | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/unit/type/hash.tcl b/tests/unit/type/hash.tcl index 2a26f4455..b3d7ddc77 100644 --- a/tests/unit/type/hash.tcl +++ b/tests/unit/type/hash.tcl @@ -363,6 +363,11 @@ start_server {tags {"hash"}} { assert_error "WRONGTYPE Operation against a key*" {r hvals wrongtype} assert_error "WRONGTYPE Operation against a key*" {r hkeys wrongtype} assert_error "WRONGTYPE Operation against a key*" {r hexists wrongtype field1} + assert_error "WRONGTYPE Operation against a key*" {r hset wrongtype field1 val1} + assert_error "WRONGTYPE Operation against a key*" {r hmset wrongtype field1 val1 field2 val2} + assert_error "WRONGTYPE Operation against a key*" {r hsetnx wrongtype field1 val1} + assert_error "WRONGTYPE Operation against a key*" {r hlen wrongtype} + assert_error "WRONGTYPE Operation against a key*" {r hscan wrongtype 0} } test {HMGET - small hash} { @@ -429,6 +434,11 @@ start_server {tags {"hash"}} { lsort [r hgetall bighash] } [lsort [array get bighash]] + test {HGETALL against non-existing key} { + r del htest + r hgetall htest + } {} + test {HDEL and return value} { set rv {} lappend rv [r hdel smallhash nokey]