MCPcopy Create free account
hub / github.com/bytebase/bytebase / newTestServerWithMock

Function newTestServerWithMock

backend/api/mcp/tool_http_test.go:20–30  ·  view source on GitHub ↗

newTestServerWithMock creates a *Server backed by a mock HTTP server. The mock server is automatically closed when the test completes.

(t *testing.T, handler http.Handler)

Source from the content-addressed store, hash-verified

18// newTestServerWithMock creates a *Server backed by a mock HTTP server.
19// The mock server is automatically closed when the test completes.
20func newTestServerWithMock(t *testing.T, handler http.Handler) *Server {
21 t.Helper()
22 mock := httptest.NewServer(handler)
23 t.Cleanup(mock.Close)
24 // Parse port from URL like "http://127.0.0.1:PORT".
25 parts := strings.Split(mock.URL, ":")
26 port, _ := strconv.Atoi(parts[len(parts)-1])
27 return &Server{
28 profile: &config.Profile{Port: port},
29 }
30}
31
32func TestApiRequest_AuthForwarding(t *testing.T) {
33 var capturedAuth string

Calls

no outgoing calls

Tested by

no test coverage detected