MCPcopy Create free account
hub / github.com/cortexproject/cortex / TestCacheKey

Function TestCacheKey

pkg/storage/tsdb/expanded_postings_cache_test.go:22–49  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

20)
21
22func TestCacheKey(t *testing.T) {
23 blockID := ulid.MustNew(1, nil)
24 seed := "seed123"
25 matchers := []*labels.Matcher{
26 {
27 Type: labels.MatchEqual,
28 Name: "name_1",
29 Value: "value_1",
30 },
31 {
32 Type: labels.MatchNotEqual,
33 Name: "name_2",
34 Value: "value_2",
35 },
36 {
37 Type: labels.MatchRegexp,
38 Name: "name_3",
39 Value: "value_4",
40 },
41 {
42 Type: labels.MatchNotRegexp,
43 Name: "name_5",
44 Value: "value_4",
45 },
46 }
47 r := cacheKey(seed, blockID, matchers...)
48 require.Equal(t, "seed123|00000000010000000000000000|name_1=value_1|name_2!=value_2|name_3=~value_4|name_5!~value_4|", r)
49}
50
51func Test_ShouldFetchPromiseOnlyOnce(t *testing.T) {
52 cfg := PostingsCacheConfig{

Callers

nothing calls this directly

Calls 2

cacheKeyFunction · 0.85
EqualMethod · 0.65

Tested by

no test coverage detected