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

Function TestServerStopDisconnectedErrCB

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

Source from the content-addressed store, hash-verified

111}
112
113func TestServerStopDisconnectedErrCB(t *testing.T) {
114 s := RunDefaultServer()
115 defer s.Shutdown()
116
117 ch := make(chan bool)
118 o := nats.GetDefaultOptions()
119 o.Url = nats.DefaultURL
120 o.AllowReconnect = false
121 o.DisconnectedErrCB = func(nc *nats.Conn, _ error) {
122 ch <- true
123 }
124 nc, err := o.Connect()
125 if err != nil {
126 t.Fatalf("Should have connected ok: %v", err)
127 }
128 defer nc.Close()
129
130 s.Shutdown()
131 if e := Wait(ch); e != nil {
132 t.Fatalf("Disconnected callback not triggered\n")
133 }
134}
135
136func TestServerSecureConnections(t *testing.T) {
137 s, opts := RunServerWithConfig("./configs/tls.conf")

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