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

Function TestConnectionStatus

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

Source from the content-addressed store, hash-verified

47}
48
49func TestConnectionStatus(t *testing.T) {
50 s := RunDefaultServer()
51 defer s.Shutdown()
52
53 nc := NewDefaultConnection(t)
54 defer nc.Close()
55
56 if nc.Status() != nats.CONNECTED || nc.Status().String() != "CONNECTED" {
57 t.Fatal("Should have status set to CONNECTED")
58 }
59
60 if !nc.IsConnected() {
61 t.Fatal("Should have status set to CONNECTED")
62 }
63 nc.Close()
64 if nc.Status() != nats.CLOSED || nc.Status().String() != "CLOSED" {
65 t.Fatal("Should have status set to CLOSED")
66 }
67 if !nc.IsClosed() {
68 t.Fatal("Should have status set to CLOSED")
69 }
70}
71
72func TestConnClosedCB(t *testing.T) {
73 s := RunDefaultServer()

Callers

nothing calls this directly

Calls 7

IsConnectedMethod · 0.80
IsClosedMethod · 0.80
RunDefaultServerFunction · 0.70
NewDefaultConnectionFunction · 0.70
StatusMethod · 0.65
CloseMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected