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

Function TestMGET

strings_test.go:316–352  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

314}
315
316func TestMGET(t *testing.T) {
317 c := getTestConn()
318 ctx := context.Background()
319
320 // Set up initial key-value pairs
321 if ok, err := c.MSet(ctx, "a", "1", "b", "2").Result(); err != nil {
322 t.Fatalf("MSET failed: %v", err)
323 } else if ok != "OK" {
324 t.Fatalf("MSET returned unexpected result: %v", ok)
325 }
326
327 // Retrieve values using MGET
328 values, err := c.MGet(ctx, "a", "b", "c").Result()
329 if err != nil {
330 t.Fatalf("MGET failed: %v", err)
331 }
332
333 // Validate the number of returned values
334 if len(values) != 3 {
335 t.Fatalf("Expected 3 values, got %d", len(values))
336 }
337
338 // Validate the value for key "a"
339 if v, ok := values[0].(string); !ok || v != "1" {
340 t.Errorf("Expected value '1' for key 'a', got %v", values[0])
341 }
342
343 // Validate the value for key "b"
344 if v, ok := values[1].(string); !ok || v != "2" {
345 t.Errorf("Expected value '2' for key 'b', got %v", values[1])
346 }
347
348 // Validate the value for non-existent key "c"
349 if values[2] != nil {
350 t.Errorf("Expected nil for non-existent key 'c', got %v", values[2])
351 }
352}
353
354func TestKVIncrDecr(t *testing.T) {
355 c := getTestConn()

Callers

nothing calls this directly

Calls 1

getTestConnFunction · 0.85

Tested by

no test coverage detected