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

Function TestEncBuiltinRequest

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

Source from the content-addressed store, hash-verified

369}
370
371func TestEncBuiltinRequest(t *testing.T) {
372 s := RunServerOnPort(TEST_PORT)
373 defer s.Shutdown()
374
375 ec := NewDefaultEConn(t)
376 defer ec.Close()
377
378 expectedResp := "I can help!"
379
380 ec.Subscribe("help", func(subj, reply, req string) {
381 ec.Publish(reply, expectedResp)
382 })
383
384 var resp string
385
386 err := ec.Request("help", "help me", &resp, 1*time.Second)
387 if err != nil {
388 t.Fatalf("Failed at receiving proper response: %v\n", err)
389 }
390 if resp != expectedResp {
391 t.Fatalf("Received reply '%s', wanted '%s'\n", resp, expectedResp)
392 }
393}
394
395func TestEncBuiltinRequestReceivesMsg(t *testing.T) {
396 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