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

Function TestQueueRecvChan

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

Source from the content-addressed store, hash-verified

179}
180
181func TestQueueRecvChan(t *testing.T) {
182 s := RunDefaultServer()
183 defer s.Shutdown()
184
185 ec := NewEConn(t)
186 defer ec.Close()
187
188 numSent := int32(22)
189 ch := make(chan int32)
190
191 if _, err := ec.BindRecvQueueChan("foo", "bar", ch); err != nil {
192 t.Fatalf("Failed to bind to a queue receive channel: %v\n", err)
193 }
194
195 ec.Publish("foo", numSent)
196
197 // Receive from 'foo'
198 select {
199 case num := <-ch:
200 if num != numSent {
201 t.Fatalf("Failed to receive correct value: %d vs %d\n", num, numSent)
202 }
203 case <-time.After(1 * time.Second):
204 t.Fatalf("Failed to receive a value, timed-out\n")
205 }
206 close(ch)
207}
208
209func TestDecoderErrRecvChan(t *testing.T) {
210 s := RunDefaultServer()

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected