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

Callers

nothing calls this directly

Calls 3

getTestConnFunction · 0.85
testHashArrayFunction · 0.85
DoMethod · 0.45

Tested by

no test coverage detected