package agentapi import ( "net/http" "strings" "testing" ) // T2: New must build a Transport with a BOUNDED, EXPIRING idle-conn pool. The earlier bare // &http.Transport{TLSClientConfig:…} had IdleConnTimeout==0 (idle keep-alives never expire) — the // leak. White-box (package agentapi) so we can read the unexported hc. // // Companion red-proof: the bare Transport gives IdleConnTimeout==0 → this test fails (demonstrated, // then reverted, during implementation). func TestNew_TransportIdlePoolBounded(t *testing.T) { c, err := New("127.0.0.1:8443", "tok", strings.Repeat("a", 64)) if err != nil { t.Fatalf("New: %v", err) } tr, ok := c.hc.Transport.(*http.Transport) if !ok { t.Fatalf("unexpected transport type %T", c.hc.Transport) } if tr.IdleConnTimeout <= 0 { t.Fatalf("IdleConnTimeout must be > 0 (idle keep-alives must expire); got %v", tr.IdleConnTimeout) } if tr.MaxIdleConnsPerHost <= 0 { t.Fatalf("MaxIdleConnsPerHost must be > 0 (bounded pool); got %d", tr.MaxIdleConnsPerHost) } }