TestHttpWithTLS_CustomTransport tests the scenario where DefaultHTTPClient has a custom Transport
(t *testing.T)
| 28 | |
| 29 | // TestHttpWithTLS_CustomTransport tests the scenario where DefaultHTTPClient has a custom Transport |
| 30 | func TestHttpWithTLS_CustomTransport(t *testing.T) { |
| 31 | // Save original transport |
| 32 | originalTransport := DefaultHTTPClient.Transport |
| 33 | defer func() { |
| 34 | DefaultHTTPClient.Transport = originalTransport |
| 35 | }() |
| 36 | |
| 37 | // Set a custom http.Transport |
| 38 | customTransport := &http.Transport{ |
| 39 | MaxIdleConns: 100, |
| 40 | } |
| 41 | DefaultHTTPClient.Transport = customTransport |
| 42 | |
| 43 | // This should not panic |
| 44 | _, err := httpWithTLS("./testdata/invalid_cert.p12", "password") |
| 45 | |
| 46 | // We expect an error (cert file not found), but NOT a panic |
| 47 | if err == nil { |
| 48 | t.Error("Expected error due to invalid cert path, but got nil") |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | // CustomRoundTripper is a custom implementation of http.RoundTripper |
| 53 | type CustomRoundTripper struct{} |
nothing calls this directly
no test coverage detected
searching dependent graphs…