MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / TestServer_Start_PortInUse

Function TestServer_Start_PortInUse

pkg/mcp/server_test.go:116–133  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

114}
115
116func TestServer_Start_PortInUse(t *testing.T) {
117 // Occupy a port.
118 l, err := net.Listen("tcp", "127.0.0.1:0")
119 if err != nil {
120 t.Fatalf("failed to listen: %v", err)
121 }
122 defer l.Close()
123 port := l.Addr().(*net.TCPAddr).Port
124
125 cfg := &Config{Host: "127.0.0.1", Port: port}
126 srv := New(cfg)
127
128 // Start should fail immediately because the port is occupied.
129 err = srv.Start(context.Background())
130 if err == nil {
131 t.Fatal("expected error when port is in use, got nil")
132 }
133}
134
135func TestServer_Start_WithAuth(t *testing.T) {
136 port := freePort(t)

Callers

nothing calls this directly

Calls 5

AddrMethod · 0.80
StartMethod · 0.80
NewFunction · 0.70
FatalfMethod · 0.65
CloseMethod · 0.45

Tested by

no test coverage detected