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

Function TestDistinctValueCollector

pkg/collector/distinct_value_collector_test.go:13–26  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

11)
12
13func TestDistinctValueCollector(t *testing.T) {
14 d := NewDistinctValue(10, 0, 0, func(s string) int { return len(s) })
15
16 require.False(t, d.Collect("123"))
17 require.False(t, d.Collect("4567"))
18 require.True(t, d.Collect("890"))
19 require.True(t, d.Exceeded())
20 stringsSlicesEqual(t, []string{"123", "4567"}, d.Values())
21
22 // diff fails when diff is not enabled
23 res, err := d.Diff()
24 require.Nil(t, res)
25 require.Error(t, err, errDiffNotEnabled)
26}
27
28func TestDistinctValueCollectorWithMaxValuesLimited(t *testing.T) {
29 d := NewDistinctValue(0, 2, 0, func(s string) int { return len(s) })

Callers

nothing calls this directly

Calls 7

NewDistinctValueFunction · 0.85
stringsSlicesEqualFunction · 0.85
CollectMethod · 0.65
ErrorMethod · 0.65
ExceededMethod · 0.45
ValuesMethod · 0.45
DiffMethod · 0.45

Tested by

no test coverage detected