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

Function TestIgnoreDiscoveredServers

nats_test.go:1198–1220  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1196}
1197
1198func TestIgnoreDiscoveredServers(t *testing.T) {
1199 opts := GetDefaultOptions()
1200 opts.IgnoreDiscoveredServers = true
1201 c := &Conn{Opts: opts}
1202 c.ps = &parseState{}
1203 c.setupServerPool()
1204
1205 if len(c.Servers()) != 1 {
1206 t.Fatalf("Expected 1 server, got %d", len(c.Servers()))
1207 }
1208
1209 err := c.parse([]byte("INFO {\"connect_urls\":[\"localhost:5222\", \"localhost:6222\"]}\r\n"))
1210 if err != nil {
1211 t.Fatalf("Unexpected: %d : %v\n", c.ps.state, err)
1212 }
1213
1214 if len(c.Servers()) != 1 {
1215 t.Fatalf("Expected 1 server, got %d: %v", len(c.Servers()), c.Servers())
1216 }
1217 if len(c.DiscoveredServers()) != 0 {
1218 t.Fatalf("Expected no discovered servers, got %v", c.DiscoveredServers())
1219 }
1220}
1221
1222func TestNoEchoOldServer(t *testing.T) {
1223 opts := GetDefaultOptions()

Callers

nothing calls this directly

Calls 6

setupServerPoolMethod · 0.95
ServersMethod · 0.95
parseMethod · 0.95
DiscoveredServersMethod · 0.95
GetDefaultOptionsFunction · 0.85
FatalfMethod · 0.80

Tested by

no test coverage detected