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

Function TestEncBuiltinExtendedSubscribeCB

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

Source from the content-addressed store, hash-verified

270}
271
272func TestEncBuiltinExtendedSubscribeCB(t *testing.T) {
273 s := RunServerOnPort(TEST_PORT)
274 defer s.Shutdown()
275
276 ec := NewDefaultEConn(t)
277 defer ec.Close()
278
279 ch := make(chan bool)
280
281 testString := "Hello World!"
282 subject := "cb_args"
283
284 ec.Subscribe(subject, func(subj, s string) {
285 if s != testString {
286 t.Fatalf("Received test string of '%s', wanted '%s'\n", s, testString)
287 }
288 if subj != subject {
289 t.Fatalf("Received subject of '%s', wanted '%s'\n", subj, subject)
290 }
291 ch <- true
292 })
293 ec.Publish(subject, testString)
294 if e := Wait(ch); e != nil {
295 if ec.LastError() != nil {
296 e = ec.LastError()
297 }
298 t.Fatalf("Did not receive the message: %s", e)
299 }
300}
301
302func TestEncBuiltinExtendedSubscribeCB2(t *testing.T) {
303 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
PublishMethod · 0.65
CloseMethod · 0.45
LastErrorMethod · 0.45

Tested by

no test coverage detected