MCPcopy
hub / github.com/nats-io/nats.go / TestSimpleRecvChan

Function TestSimpleRecvChan

test/netchan_test.go:153–179  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

151}
152
153func TestSimpleRecvChan(t *testing.T) {
154 s := RunDefaultServer()
155 defer s.Shutdown()
156
157 ec := NewEConn(t)
158 defer ec.Close()
159
160 numSent := int32(22)
161 ch := make(chan int32)
162
163 if _, err := ec.BindRecvChan("foo", ch); err != nil {
164 t.Fatalf("Failed to bind to a receive channel: %v\n", err)
165 }
166
167 ec.Publish("foo", numSent)
168
169 // Receive from 'foo'
170 select {
171 case num := <-ch:
172 if num != numSent {
173 t.Fatalf("Failed to receive correct value: %d vs %d\n", num, numSent)
174 }
175 case <-time.After(1 * time.Second):
176 t.Fatalf("Failed to receive a value, timed-out\n")
177 }
178 close(ch)
179}
180
181func TestQueueRecvChan(t *testing.T) {
182 s := RunDefaultServer()

Callers

nothing calls this directly

Calls 6

NewEConnFunction · 0.85
BindRecvChanMethod · 0.80
FatalfMethod · 0.80
RunDefaultServerFunction · 0.70
PublishMethod · 0.65
CloseMethod · 0.45

Tested by

no test coverage detected