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

Function TestConnClosedCB

test/conn_test.go:72–90  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

70}
71
72func TestConnClosedCB(t *testing.T) {
73 s := RunDefaultServer()
74 defer s.Shutdown()
75
76 ch := make(chan bool)
77 o := nats.GetDefaultOptions()
78 o.Url = nats.DefaultURL
79 o.ClosedCB = func(_ *nats.Conn) {
80 ch <- true
81 }
82 nc, err := o.Connect()
83 if err != nil {
84 t.Fatalf("Should have connected ok: %v", err)
85 }
86 nc.Close()
87 if e := Wait(ch); e != nil {
88 t.Fatalf("Closed callback not triggered\n")
89 }
90}
91
92func TestCloseDisconnectedErrCB(t *testing.T) {
93 s := RunDefaultServer()

Callers

nothing calls this directly

Calls 5

ConnectMethod · 0.80
FatalfMethod · 0.80
RunDefaultServerFunction · 0.70
WaitFunction · 0.70
CloseMethod · 0.45

Tested by

no test coverage detected