MCPcopy
hub / github.com/grafana/dskit / TestLRUCache_GetMultiWithError

Function TestLRUCache_GetMultiWithError

cache/lru_test.go:133–152  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

131}
132
133func TestLRUCache_GetMultiWithError(t *testing.T) {
134 mock := NewMockCache()
135 ctx := context.Background()
136 mock.SetMultiAsync(map[string][]byte{"backend": []byte("backend-value")}, time.Hour)
137
138 reg := prometheus.NewPedanticRegistry()
139 lru, err := WrapWithLRUCache(mock, "test", reg, 10000, 2*time.Hour, log.NewNopLogger())
140 require.NoError(t, err)
141
142 lru.SetMultiAsync(map[string][]byte{
143 "lru": []byte("lru-value"),
144 }, time.Minute)
145
146 result, err := lru.GetMultiWithError(ctx, []string{"lru", "backend", "missing"})
147 require.NoError(t, err)
148 require.Equal(t, map[string][]byte{
149 "lru": []byte("lru-value"),
150 "backend": []byte("backend-value"),
151 }, result)
152}
153
154func TestLRUCache_GetMultiWithError_PropagatesError(t *testing.T) {
155 backendErr := errors.New("backend error")

Callers

nothing calls this directly

Calls 6

SetMultiAsyncMethod · 0.95
NewMockCacheFunction · 0.85
WrapWithLRUCacheFunction · 0.85
SetMultiAsyncMethod · 0.65
GetMultiWithErrorMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected