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

Function TestCloseDisconnectedErrCB

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

Source from the content-addressed store, hash-verified

90}
91
92func TestCloseDisconnectedErrCB(t *testing.T) {
93 s := RunDefaultServer()
94 defer s.Shutdown()
95
96 ch := make(chan bool)
97 o := nats.GetDefaultOptions()
98 o.Url = nats.DefaultURL
99 o.AllowReconnect = false
100 o.DisconnectedErrCB = func(_ *nats.Conn, _ error) {
101 ch <- true
102 }
103 nc, err := o.Connect()
104 if err != nil {
105 t.Fatalf("Should have connected ok: %v", err)
106 }
107 nc.Close()
108 if e := Wait(ch); e != nil {
109 t.Fatal("Disconnected callback not triggered")
110 }
111}
112
113func TestServerStopDisconnectedErrCB(t *testing.T) {
114 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