package connector_callout

import (
	"testing"
)

// TestEngineHTTPClientIsRequired verifies that Engine requires a non-nil
// HTTPClient injected via NewEngine. The zero value (nil HTTPClient) is not
// usable — the adapter caches the transport at construction time, so callers
// must pass a non-nil client.
//
// Transport reuse (the B45 concern formerly exercised by defaultClientOnce)
// is now the responsibility of the adapter implementation
// (infrastructure/http_client.OutboundClient), which caches its inner
// http.Client at adapter construction time and reuses it across all Do calls.
// This test verifies the engine stores and returns the injected adapter.
func TestEngineHTTPClientIsRequired(t *testing.T) {
	adapter := loopbackHTTPClient()
	e := NewEngine(&mockCredentialResolver{}, &mockThrottler{}, adapter, testAllowlistForEngine())

	if e.HTTPClient == nil {
		t.Fatal("Engine.HTTPClient must not be nil after NewEngine")
	}
	if e.HTTPClient != adapter {
		t.Error("Engine.HTTPClient must be exactly the adapter passed to NewEngine")
	}
}
