package controlplane_test

import (
	"os"
	"testing"

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

// TestMain wires the control-plane seam ports before any controlplane test runs.
//
// The controlplane package no longer imports internal/bootstrap; its seam vars
// (bootstrapStateStore, schemaProvisioner, fieldProvenanceInitializer,
// getActionSchema) are declared nil and must be injected by a composition root.
// The controlplane tests are the proof-of-injection for the apply/verify path:
// default-build tests already exercise it without a real DB — e.g.
// apply_all_if_needed_test.go drives ApplyAllIfNeededWithOptions over sqlmock,
// which calls bootstrapStateStore.ClassifyControlPlaneAutoStart /
// MarkControlPlaneApplyAll* — and the integration tests exercise the schema /
// state-store / getActionSchema surface end to end. Without this wiring those
// tests nil-deref.
//
// No //go:build tag: this TestMain must govern BOTH the default and the
// integration test binaries, because both contain seam-exercising tests.
//
// 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())
}
