MCPcopy
hub / github.com/grafana/tempo / TestList

Function TestList

tempodb/backend/cache/cache_test.go:231–270  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

229}
230
231func TestList(t *testing.T) {
232 tenantID := "test"
233 blockID := uuid.New()
234
235 tests := []struct {
236 name string
237 readerList []string
238 expectedList []string
239 expectedCache []string
240 }{
241 {
242 name: "list passthrough",
243 readerList: []string{"1"},
244 expectedList: []string{"1"},
245 expectedCache: nil,
246 },
247 }
248
249 for _, tt := range tests {
250 t.Run(tt.name, func(t *testing.T) {
251 mockR := &backend.MockRawReader{
252 L: tt.readerList,
253 }
254 mockW := &backend.MockRawWriter{}
255
256 rw, _, _ := NewCache(nil, mockR, mockW, test.NewMockProvider(), log.NewNopLogger())
257
258 ctx := context.Background()
259 list, _ := rw.List(ctx, backend.KeyPathForBlock(blockID, tenantID))
260 assert.Equal(t, tt.expectedList, list)
261
262 // clear reader and re-request. things should be cached!
263 mockR.L = nil
264
265 // list is not cached
266 list, _ = rw.List(ctx, backend.KeyPathForBlock(blockID, tenantID))
267 assert.Equal(t, tt.expectedCache, list)
268 })
269 }
270}
271
272func TestCacheKeys(t *testing.T) {
273 provider := test.NewMockProvider()

Callers

nothing calls this directly

Calls 6

NewMockProviderFunction · 0.92
KeyPathForBlockFunction · 0.92
NewCacheFunction · 0.85
ListMethod · 0.65
RunMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected