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

Function TestHashGetAll

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

Source from the content-addressed store, hash-verified

180 t.Fatal(err)
181 }
182}
183
184func TestHashGetAll(t *testing.T) {
185 c := getTestConn()
186
187 ctx := context.Background()
188 key := []byte("d")
189
190 if ok, err := c.Do(ctx, "hmset", key, 1, 1, 2, 2, 3, 3).Result(); err != nil {
191 t.Fatal(err)
192 } else if ok != "OK" {
193 t.Fatal(ok)
194 }
195
196 if v, err := c.Do(ctx, "hgetall", key).Result(); err != nil {
197 t.Fatal(err)
198 } else {
199 if err := testHashArray(cast.ToSlice(v), 1, 1, 2, 2, 3, 3); err != nil {
200 t.Fatal(err)
201 }
202 }
203
204 if v, err := c.Do(ctx, "hkeys", key).Result(); err != nil {
205 t.Fatal(err)
206 } else {
207 if err := testHashArray(cast.ToSlice(v), 1, 2, 3); err != nil {
208 t.Fatal(err)
209 }
210 }
211
212 if v, err := c.Do(ctx, "hvals", key).Result(); err != nil {
213 t.Fatal(err)
214 } else {
215 if err := testHashArray(cast.ToSlice(v), 1, 2, 3); err != nil {
216 t.Fatal(err)
217 }
218 }
219
220 if n, err := c.Do(ctx, "hclear", key).Int64(); err != nil {
221 t.Fatal(err)
222 } else if n != 3 {
223 t.Fatal(n)
224 }
225
226 if n, err := c.Do(ctx, "hlen", key).Int64(); err != nil {
227 t.Fatal(err)
228 } else if n != 0 {
229 t.Fatal(n)
230 }
231}
232

Callers

nothing calls this directly

Calls 3

getTestConnFunction · 0.85
testHashArrayFunction · 0.85
DoMethod · 0.45

Tested by

no test coverage detected