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

Function TestCacheCaches

modules/frontend/pipeline/sync_handler_cache_test.go:22–48  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

20}
21
22func TestCacheCaches(t *testing.T) {
23 expected := &tempopb.SearchTagsResponse{
24 TagNames: []string{"foo", "bar"},
25 }
26
27 // marshal mesage to bytes
28 buf := bytes.NewBuffer([]byte{})
29 err := (&jsonpb.Marshaler{}).Marshal(buf, expected)
30 require.NoError(t, err)
31
32 testKey := "key"
33 testData := buf.Bytes()
34
35 p := test.NewMockProvider()
36 c := newFrontendCache(p, cache.RoleBloom, log.NewNopLogger())
37 require.NotNil(t, c)
38
39 // create response
40 c.store(context.Background(), testKey, testData)
41
42 actual := &tempopb.SearchTagsResponse{}
43 buffer := c.fetchBytes(context.Background(), testKey)
44 err = (&jsonpb.Unmarshaler{AllowUnknownFields: true}).Unmarshal(bytes.NewReader(buffer), actual)
45
46 require.NoError(t, err)
47 require.Equal(t, expected, actual)
48}
49
50func TestDetermineContentType(t *testing.T) {
51 // Create and marshal a real protobuf message

Callers

nothing calls this directly

Calls 8

NewMockProviderFunction · 0.92
newFrontendCacheFunction · 0.85
BytesMethod · 0.80
storeMethod · 0.80
fetchBytesMethod · 0.80
MarshalMethod · 0.65
UnmarshalMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected