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

Function TestConnectedServer

test/basic_test.go:128–183  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

126}
127
128func TestConnectedServer(t *testing.T) {
129 s := RunDefaultServer()
130 defer s.Shutdown()
131
132 nc := NewDefaultConnection(t)
133 defer nc.Close()
134
135 u := nc.ConnectedUrl()
136 if u == "" || u != nats.DefaultURL {
137 t.Fatalf("Unexpected connected URL of %s\n", u)
138 }
139 id := nc.ConnectedServerId()
140 if id == "" {
141 t.Fatalf("Expected a connected server id, got %s", id)
142 }
143 name := nc.ConnectedServerName()
144 if name == "" {
145 t.Fatalf("Expected a connected server name, got %s", name)
146 }
147 cname := nc.ConnectedClusterName()
148 if cname == "" {
149 t.Fatalf("Expected a connected server cluster name, got %s", cname)
150 }
151 jsEnabled, _ := nc.ConnectedServerJetStream()
152 if jsEnabled {
153 t.Fatalf("Expected JetStream to be disabled")
154 }
155 if nc.IsSystemAccount() {
156 t.Fatalf("Expected non-system account")
157 }
158
159 nc.Close()
160 u = nc.ConnectedUrl()
161 if u != "" {
162 t.Fatalf("Expected a nil connected URL, got %s\n", u)
163 }
164 id = nc.ConnectedServerId()
165 if id != "" {
166 t.Fatalf("Expected a nil connect server, got %s", id)
167 }
168 name = nc.ConnectedServerName()
169 if name != "" {
170 t.Fatalf("Expected a nil connect server name, got %s", name)
171 }
172 cname = nc.ConnectedClusterName()
173 if cname != "" {
174 t.Fatalf("Expected a nil connect server cluster, got %s", cname)
175 }
176 jsEnabled, _ = nc.ConnectedServerJetStream()
177 if jsEnabled {
178 t.Fatalf("Expected JetStream to be disabled after close")
179 }
180 if nc.IsSystemAccount() {
181 t.Fatalf("Expected non-system account after close")
182 }
183}
184
185func TestConnectedServerJetStream(t *testing.T) {

Callers

nothing calls this directly

Calls 10

ConnectedUrlMethod · 0.80
FatalfMethod · 0.80
ConnectedServerIdMethod · 0.80
ConnectedServerNameMethod · 0.80
ConnectedClusterNameMethod · 0.80
IsSystemAccountMethod · 0.80
RunDefaultServerFunction · 0.70
NewDefaultConnectionFunction · 0.70
CloseMethod · 0.45

Tested by

no test coverage detected