MCPcopy Index your code
hub / github.com/devaccuracy/ledgerforge / TestGet

Function TestGet

internal/cache/cache_test.go:66–88  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

64}
65
66func TestGet(t *testing.T) {
67 config.ConfigStore.Store(newTestRedisConfig(t))
68 ctx := context.Background()
69 mockCache, err := NewCache()
70 assert.NoError(t, err)
71
72 key := "testKey"
73 setValue := map[string]string{"hello": "world"}
74 err = mockCache.Set(ctx, key, setValue, 10*time.Minute)
75 assert.NoError(t, err)
76
77 // Test getting an existing value
78 var getValue map[string]string
79 err = mockCache.Get(ctx, key, &getValue)
80 assert.NoError(t, err)
81 assert.Equal(t, setValue, getValue)
82
83 var getValue1 map[string]string
84 // Test getting a non-existent key
85 err = mockCache.Get(ctx, "nonExistentKey", &getValue1)
86 assert.NoError(t, err) // Assuming Get returns no error for non-existent keys
87 assert.Empty(t, getValue1)
88}
89
90func TestGetNonExistentKey(t *testing.T) {
91 config.ConfigStore.Store(newTestRedisConfig(t))

Callers

nothing calls this directly

Calls 4

SetMethod · 0.95
GetMethod · 0.95
newTestRedisConfigFunction · 0.85
NewCacheFunction · 0.85

Tested by

no test coverage detected