package packs_test

import (
	"os"
	"testing"

	"github.com/pingcap-inc/nexuscrm-controlplane/internal/seamtestwiring"
)

// TestMain wires the control-plane seam ports before any packs test runs.
//
// The packs package no longer imports internal/bootstrap; its seam vars
// (schemaProvisioner, fieldProvenanceInitializer, autoNumberSeeder,
// resolveFieldMapping, resolvePackConnectorFieldMapping, getFieldMappings,
// standardFlowActiveVersionIsPackOwned) are declared nil and must be injected by
// a composition root. The packs tests are the proof-of-injection for the apply
// path: several default tests call these seams directly (e.g.
// runtime_metadata_test.go calls fieldProvenanceInitializer methods;
// connector_field_mapping_relocated_test.go calls getFieldMappings;
// standard_flows_test_relocated_test.go calls standardFlowActiveVersionIsPackOwned),
// and the integration tests exercise the schema/autonumber/resolve apply path.
// Without this wiring those tests nil-deref.
//
// seamtestwiring.Wire() preserves the RegisterPlatformDeclaredAutoNumberSeeds()
// call that previously ran in the bootstrap-backed wiring.
//
// As of PR2 this wires the seams directly from the neutral homes
// (controlplane/bootstrapimpl + db) via the internal seamtestwiring helper —
// NOT through backend/pkg/serverruntime — so no file under the controlplane
// module imports backend (the controlplane->backend dependency PR2 severs).
func TestMain(m *testing.M) {
	seamtestwiring.Wire()
	os.Exit(m.Run())
}
