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

Function TestEncBuiltinRawMsgSubscribeCB

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

Source from the content-addressed store, hash-verified

334}
335
336func TestEncBuiltinRawMsgSubscribeCB(t *testing.T) {
337 s := RunServerOnPort(TEST_PORT)
338 defer s.Shutdown()
339
340 ec := NewDefaultEConn(t)
341 defer ec.Close()
342
343 ch := make(chan bool)
344
345 testString := "Hello World!"
346 oSubj := "cb_args"
347 oReply := "foobar"
348
349 ec.Subscribe(oSubj, func(m *nats.Msg) {
350 s := string(m.Data)
351 if s != testString {
352 t.Fatalf("Received test string of '%s', wanted '%s'\n", s, testString)
353 }
354 if m.Subject != oSubj {
355 t.Fatalf("Received subject of '%s', wanted '%s'\n", m.Subject, oSubj)
356 }
357 if m.Reply != oReply {
358 t.Fatalf("Received reply of '%s', wanted '%s'\n", m.Reply, oReply)
359 }
360 ch <- true
361 })
362 ec.PublishRequest(oSubj, oReply, testString)
363 if e := Wait(ch); e != nil {
364 if ec.LastError() != nil {
365 e = ec.LastError()
366 }
367 t.Fatalf("Did not receive the message: %s", e)
368 }
369}
370
371func TestEncBuiltinRequest(t *testing.T) {
372 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