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

Function TestWordCounter

pkg/usagestats/stats_test.go:151–165  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

149}
150
151func TestWordCounter(t *testing.T) {
152 w := NewWordCounter("test_words_count")
153 var wg sync.WaitGroup
154 for i := 0; i < 100; i++ {
155 wg.Add(1)
156 go func() {
157 defer wg.Done()
158 w.Add("foo")
159 w.Add("bar")
160 w.Add("foo")
161 }()
162 }
163 wg.Wait()
164 require.Equal(t, int64(2), w.Value())
165}
166
167func TestPanics(t *testing.T) {
168 require.Panics(t, func() {

Callers

nothing calls this directly

Calls 7

AddMethod · 0.95
ValueMethod · 0.95
NewWordCounterFunction · 0.85
AddMethod · 0.65
DoneMethod · 0.65
WaitMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected