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)
| 18 | // newTestServerWithMock creates a *Server backed by a mock HTTP server. |
| 19 | // The mock server is automatically closed when the test completes. |
| 20 | func 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 | |
| 32 | func TestApiRequest_AuthForwarding(t *testing.T) { |
| 33 | var capturedAuth string |
no outgoing calls
no test coverage detected