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

Function TestRequestLeaksMapEntries

test/nats_test.go:836–862  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

834}
835
836func TestRequestLeaksMapEntries(t *testing.T) {
837 o := natsserver.DefaultTestOptions
838 o.Port = -1
839 s := RunServerWithOptions(&o)
840 defer s.Shutdown()
841
842 nc, err := nats.Connect(fmt.Sprintf("nats://%s:%d", o.Host, o.Port))
843 if err != nil {
844 t.Fatalf("Error on connect: %v", err)
845 }
846 defer nc.Close()
847
848 response := []byte("I will help you")
849 nc.Subscribe("foo", func(m *nats.Msg) {
850 nc.Publish(m.Reply, response)
851 })
852
853 for i := 0; i < 100; i++ {
854 msg, err := nc.Request("foo", nil, 500*time.Millisecond)
855 if err != nil {
856 t.Fatalf("Received an error on Request test: %s", err)
857 }
858 if !bytes.Equal(msg.Data, response) {
859 t.Fatalf("Received invalid response")
860 }
861 }
862}
863
864func TestRequestMultipleReplies(t *testing.T) {
865 o := natsserver.DefaultTestOptions

Callers

nothing calls this directly

Calls 8

ConnectMethod · 0.80
FatalfMethod · 0.80
EqualMethod · 0.80
RunServerWithOptionsFunction · 0.70
SubscribeMethod · 0.65
PublishMethod · 0.65
CloseMethod · 0.45
RequestMethod · 0.45

Tested by

no test coverage detected