From e60aa6e71ff1ee03f36401da79d93beb432ac97e Mon Sep 17 00:00:00 2001 From: QlQl <2458371920@qq.com> Date: Wed, 31 Jul 2024 16:57:26 +0800 Subject: [PATCH] add hincrby cmd test --- tests/hash_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/hash_test.go b/tests/hash_test.go index ca28c585f..2fc1efbe9 100644 --- a/tests/hash_test.go +++ b/tests/hash_test.go @@ -195,6 +195,27 @@ var _ = Describe("Hash", Ordered, func() { Expect(length.Val()).To(Equal(int64(len("hello1")))) }) + It("should HIncrBy against wrong metadata", func() { + hSet := client.HSet(ctx, "hash", "key", "5") + Expect(hSet.Err()).NotTo(HaveOccurred()) + + hIncrBy := client.HIncrBy(ctx, "hash", "key", 1) + Expect(hIncrBy.Err()).NotTo(HaveOccurred()) + Expect(hIncrBy.Val()).To(Equal(int64(6))) + + hDel := client.HDel(ctx, "hash", "key") + Expect(hDel.Err()).NotTo(HaveOccurred()) + Expect(hDel.Val()).To(Equal(int64(1))) + + hIncrBy = client.HIncrBy(ctx, "hash", "key", 1) + Expect(hIncrBy.Err()).NotTo(HaveOccurred()) + Expect(hIncrBy.Val()).To(Equal(int64(1))) + + hIncrBy = client.HIncrBy(ctx, "hash", "key", 2) + Expect(hIncrBy.Err()).NotTo(HaveOccurred()) + Expect(hIncrBy.Val()).To(Equal(int64(3))) + }) + It("HIncrbyFloat", func() { hSet := client.HSet(ctx, "hash", "field", "10.50") Expect(hSet.Err()).NotTo(HaveOccurred())