package controlplane

import (
	"strings"
	"testing"
)

func TestPackOwnedFieldRemovalStaysOutOfSourcePackOps(t *testing.T) {
	opsSrc := readControlplaneSourceForStructureTest(t, "source_pack_ops.go")
	removalSrc := readControlplaneSourceForStructureTest(t, "source_pack_field_removal.go")

	for _, symbol := range []string{
		"func RemovePackOwnedField(",
		"func removePackOwnedFieldUnlocked(",
		"type packOwnedFieldRemovalPreflight struct",
		"func loadPackOwnedFieldRemovalPreflight(",
	} {
		if strings.Contains(opsSrc, symbol) {
			t.Fatalf("source_pack_ops.go still owns pack-owned field removal symbol %q", symbol)
		}
		if !strings.Contains(removalSrc, symbol) {
			t.Fatalf("source_pack_field_removal.go is missing pack-owned field removal symbol %q", symbol)
		}
	}
}

func TestPackOwnedFieldRemovalCarriesRunnerRegistrationSet(t *testing.T) {
	removalSrc := readControlplaneSourceForStructureTest(t, "source_pack_field_removal.go")
	for _, fragment := range []string{
		"IsFieldDeclaredByCurrentSourceForExplicitRemovalWithComponentKindRegistrationSet(",
		"r.componentKindRegistrationSet()",
	} {
		if !strings.Contains(removalSrc, fragment) {
			t.Fatalf("source_pack_field_removal.go is missing registration carrier %q", fragment)
		}
	}
}
