MCPcopy
hub / github.com/silenceper/wechat / TestHttpWithTLS_CustomTransport

Function TestHttpWithTLS_CustomTransport

util/http_test.go:30–50  ·  view source on GitHub ↗

TestHttpWithTLS_CustomTransport tests the scenario where DefaultHTTPClient has a custom Transport

(t *testing.T)

Source from the content-addressed store, hash-verified

28
29// TestHttpWithTLS_CustomTransport tests the scenario where DefaultHTTPClient has a custom Transport
30func 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
53type CustomRoundTripper struct{}

Callers

nothing calls this directly

Calls 2

httpWithTLSFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…