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

Function TestEncBuiltinExtendedSubscribeCB2

test/enc_test.go:302–334  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

300}
301
302func TestEncBuiltinExtendedSubscribeCB2(t *testing.T) {
303 s := RunServerOnPort(TEST_PORT)
304 defer s.Shutdown()
305
306 ec := NewDefaultEConn(t)
307 defer ec.Close()
308
309 ch := make(chan bool)
310
311 testString := "Hello World!"
312 oSubj := "cb_args"
313 oReply := "foobar"
314
315 ec.Subscribe(oSubj, func(subj, reply, s string) {
316 if s != testString {
317 t.Fatalf("Received test string of '%s', wanted '%s'\n", s, testString)
318 }
319 if subj != oSubj {
320 t.Fatalf("Received subject of '%s', wanted '%s'\n", subj, oSubj)
321 }
322 if reply != oReply {
323 t.Fatalf("Received reply of '%s', wanted '%s'\n", reply, oReply)
324 }
325 ch <- true
326 })
327 ec.PublishRequest(oSubj, oReply, testString)
328 if e := Wait(ch); e != nil {
329 if ec.LastError() != nil {
330 e = ec.LastError()
331 }
332 t.Fatalf("Did not receive the message: %s", e)
333 }
334}
335
336func TestEncBuiltinRawMsgSubscribeCB(t *testing.T) {
337 s := RunServerOnPort(TEST_PORT)

Callers

nothing calls this directly

Calls 8

NewDefaultEConnFunction · 0.85
FatalfMethod · 0.80
RunServerOnPortFunction · 0.70
WaitFunction · 0.70
SubscribeMethod · 0.65
CloseMethod · 0.45
PublishRequestMethod · 0.45
LastErrorMethod · 0.45

Tested by

no test coverage detected