MCPcopy Create free account
hub / github.com/IceFireDB/IceFireDB / TestHashM

Function TestHashM

hashes_test.go:93–144  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

91}
92
93func TestHashM(t *testing.T) {
94 c := getTestConn()
95
96 ctx := context.Background()
97
98 key := []byte("b")
99 if ok, err := c.Do(ctx, "hmset", key, 1, 1, 2, 2, 3, 3).Text(); err != nil {
100 t.Fatal(err)
101 } else if ok != "OK" {
102 t.Fatal(ok)
103 }
104
105 if n, err := c.Do(ctx, "hlen", key).Int64(); err != nil {
106 t.Fatal(err)
107 } else if n != 3 {
108 t.Fatal(n)
109 }
110
111 if v, err := c.Do(ctx, "hmget", key, 1, 2, 3, 4).Result(); err != nil {
112 t.Fatal(err)
113 } else {
114 if err := testHashArray(cast.ToSlice(v), 1, 2, 3, 0); err != nil {
115 t.Fatal(err)
116 }
117 }
118
119 if n, err := c.Do(ctx, "hdel", key, 1, 2, 3, 4).Int64(); err != nil {
120 t.Fatal(err)
121 } else if n != 3 {
122 t.Fatal(n)
123 }
124
125 if n, err := c.Do(ctx, "hlen", key).Int64(); err != nil {
126 t.Fatal(err)
127 } else if n != 0 {
128 t.Fatal(n)
129 }
130
131 if v, err := c.Do(ctx, "hmget", key, 1, 2, 3, 4).Result(); err != nil {
132 t.Fatal(err)
133 } else {
134 if err := testHashArray(cast.ToSlice(v), 0, 0, 0, 0); err != nil {
135 t.Fatal(err)
136 }
137 }
138
139 if n, err := c.Do(ctx, "hlen", key).Int64(); err != nil {
140 t.Fatal(err)
141 } else if n != 0 {
142 t.Fatal(n)
143 }
144}
145
146func TestHashIncr(t *testing.T) {
147 c := getTestConn()

Callers

nothing calls this directly

Calls 3

getTestConnFunction · 0.85
testHashArrayFunction · 0.85
DoMethod · 0.45

Tested by

no test coverage detected