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

Function TestEncBuiltinRequestReceivesMsg

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

Source from the content-addressed store, hash-verified

393}
394
395func TestEncBuiltinRequestReceivesMsg(t *testing.T) {
396 s := RunServerOnPort(TEST_PORT)
397 defer s.Shutdown()
398
399 ec := NewDefaultEConn(t)
400 defer ec.Close()
401
402 expectedResp := "I can help!"
403
404 ec.Subscribe("help", func(subj, reply, req string) {
405 ec.Publish(reply, expectedResp)
406 })
407
408 var resp nats.Msg
409
410 err := ec.Request("help", "help me", &resp, 1*time.Second)
411 if err != nil {
412 t.Fatalf("Failed at receiving proper response: %v\n", err)
413 }
414 if string(resp.Data) != expectedResp {
415 t.Fatalf("Received reply '%s', wanted '%s'\n", string(resp.Data), expectedResp)
416 }
417}
418
419func TestEncBuiltinAsyncMarshalErr(t *testing.T) {
420 s := RunServerOnPort(TEST_PORT)

Callers

nothing calls this directly

Calls 7

NewDefaultEConnFunction · 0.85
FatalfMethod · 0.80
RunServerOnPortFunction · 0.70
SubscribeMethod · 0.65
PublishMethod · 0.65
CloseMethod · 0.45
RequestMethod · 0.45

Tested by

no test coverage detected