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

Function TestIsClosed

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

Source from the content-addressed store, hash-verified

401}
402
403func TestIsClosed(t *testing.T) {
404 ts := startReconnectServer(t)
405 defer ts.Shutdown()
406
407 nc := NewConnection(t, TEST_PORT)
408 defer nc.Close()
409
410 if nc.IsClosed() {
411 t.Fatalf("IsClosed returned true when the connection is still open.")
412 }
413 ts.Shutdown()
414 if nc.IsClosed() {
415 t.Fatalf("IsClosed returned true when the connection is still open.")
416 }
417 ts = startReconnectServer(t)
418 defer ts.Shutdown()
419 if nc.IsClosed() {
420 t.Fatalf("IsClosed returned true when the connection is still open.")
421 }
422 nc.Close()
423 if !nc.IsClosed() {
424 t.Fatalf("IsClosed returned false after Close() was called.")
425 }
426}
427
428func TestIsReconnectingAndStatus(t *testing.T) {
429 ts := startReconnectServer(t)

Callers

nothing calls this directly

Calls 5

startReconnectServerFunction · 0.85
IsClosedMethod · 0.80
FatalfMethod · 0.80
NewConnectionFunction · 0.70
CloseMethod · 0.45

Tested by

no test coverage detected