Skip to content

Commit 15a6cac

Browse files
author
Guo Hui
committed
fix: Improve HSet unit tests
1 parent 89bfe30 commit 15a6cac

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

commands_test.go

+10-2
Original file line numberDiff line numberDiff line change
@@ -2579,18 +2579,26 @@ var _ = Describe("Commands", func() {
25792579
"val",
25802580
}))
25812581

2582-
type set2 struct {
2582+
type setOmitEmpty struct {
25832583
Set1 string `redis:"set1"`
25842584
Set2 int `redis:"set2,omitempty"`
25852585
Set3 time.Duration `redis:"set3,omitempty"`
25862586
Set4 string `redis:"set4,omitempty"`
25872587
Set5 time.Time `redis:"set5,omitempty"`
25882588
}
2589-
hSet = client.HSet(ctx, "hash3", &set2{
2589+
hSet = client.HSet(ctx, "hash3", &setOmitEmpty{
25902590
Set1: "val",
25912591
})
25922592
Expect(hSet.Err()).NotTo(HaveOccurred())
25932593
Expect(hSet.Val()).To(Equal(int64(1)))
2594+
2595+
var dest setOmitEmpty
2596+
hGetAll := client.HGetAll(ctx, "hash3")
2597+
Expect(hGetAll.Err()).NotTo(HaveOccurred())
2598+
Expect(hGetAll.Val()).To(Equal(map[string]string{
2599+
"set1": "val",
2600+
}))
2601+
Expect(hGetAll.Scan(&dest)).NotTo(HaveOccurred())
25942602
})
25952603

25962604
It("should HSetNX", func() {

0 commit comments

Comments
 (0)