MCPcopy Create free account
hub / github.com/eapache/channels / testTee

Function testTee

channels_test.go:114–146  ·  view source on GitHub ↗
(t *testing.T, tee func(input SimpleOutChannel, outputs ...SimpleInChannel))

Source from the content-addressed store, hash-verified

112}
113
114func testTee(t *testing.T, tee func(input SimpleOutChannel, outputs ...SimpleInChannel)) {
115 a := NewNativeChannel(None)
116 b := NewNativeChannel(None)
117
118 tee(a, b)
119
120 testChannelPair(t, "simple tee", a, b)
121
122 a = NewNativeChannel(None)
123 outputs := []Channel{
124 NewNativeChannel(None),
125 NewNativeChannel(None),
126 NewNativeChannel(None),
127 NewNativeChannel(None),
128 }
129
130 tee(a, outputs[0], outputs[1], outputs[2], outputs[3])
131
132 go func() {
133 for i := 0; i < 1000; i++ {
134 a.In() <- i
135 }
136 a.Close()
137 }()
138 for i := 0; i < 1000; i++ {
139 for _, output := range outputs {
140 val := <-output.Out()
141 if i != val.(int) {
142 t.Fatal("teeing expected", i, "but got", val.(int))
143 }
144 }
145 }
146}
147
148func TestTee(t *testing.T) {
149 testTee(t, Tee)

Callers 2

TestTeeFunction · 0.85
TestWeakTeeFunction · 0.85

Calls 6

InMethod · 0.95
CloseMethod · 0.95
NewNativeChannelFunction · 0.85
teeFunction · 0.85
testChannelPairFunction · 0.85
OutMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…