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

Function TestReconnectDisallowedFlags

test/reconnect_test.go:58–80  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

56}
57
58func TestReconnectDisallowedFlags(t *testing.T) {
59 ts := startReconnectServer(t)
60 defer ts.Shutdown()
61
62 ch := make(chan bool)
63 opts := nats.GetDefaultOptions()
64 opts.Url = fmt.Sprintf("nats://127.0.0.1:%d", TEST_PORT)
65 opts.AllowReconnect = false
66 opts.ClosedCB = func(_ *nats.Conn) {
67 ch <- true
68 }
69 nc, err := opts.Connect()
70 if err != nil {
71 t.Fatalf("Should have connected ok: %v", err)
72 }
73 defer nc.Close()
74
75 ts.Shutdown()
76
77 if e := Wait(ch); e != nil {
78 t.Fatal("Did not trigger ClosedCB correctly")
79 }
80}
81
82func TestReconnectAllowedFlags(t *testing.T) {
83 ts := startReconnectServer(t)

Callers

nothing calls this directly

Calls 5

startReconnectServerFunction · 0.85
ConnectMethod · 0.80
FatalfMethod · 0.80
WaitFunction · 0.70
CloseMethod · 0.45

Tested by

no test coverage detected