MCPcopy
hub / github.com/livekit/livekit / TestForEach

Function TestForEach

pkg/utils/incrementaldispatcher_test.go:33–48  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

31)
32
33func TestForEach(t *testing.T) {
34 producer := utils.NewIncrementalDispatcher[int]()
35 go func() {
36 defer producer.Done()
37 producer.Add(1)
38 producer.Add(2)
39 producer.Add(3)
40 }()
41
42 sum := 0
43 producer.ForEach(func(item int) {
44 sum += item
45 })
46
47 require.Equal(t, 6, sum)
48}
49
50func TestConcurrentConsumption(t *testing.T) {
51 producer := utils.NewIncrementalDispatcher[int]()

Callers

nothing calls this directly

Calls 3

DoneMethod · 0.80
ForEachMethod · 0.80
AddMethod · 0.45

Tested by

no test coverage detected