package packs

import (
	"strings"
	"testing"
)

func TestSourceBackedConnectorBuildersStayOutOfGeneralBuilderFile(t *testing.T) {
	generalSrc := readPacksSourceForStructureTest(t, "source_backed_component_builders.go")
	connectorSrc := readPacksSourceForStructureTest(t, "source_backed_connector_component_builders.go")

	for _, symbol := range []string{
		"func (b *sourceBackedComponentBuildContext) buildWebhookSecret(",
		"func (b *sourceBackedComponentBuildContext) buildConnectorCapability(",
		"func (b *sourceBackedComponentBuildContext) buildConnectorRateLimit(",
		"func (b *sourceBackedComponentBuildContext) buildConnectorInboundHandlerConfig(",
		"func (b *sourceBackedComponentBuildContext) buildConnectorInboundRoute(",
		"func (b *sourceBackedComponentBuildContext) buildConnectorCalloutProfile(",
		"func (b *sourceBackedComponentBuildContext) buildConnectorFieldMapping(",
		"func (b *sourceBackedComponentBuildContext) buildConnectorPushContract(",
		"func (b *sourceBackedComponentBuildContext) requireConnectorPack(",
		"func componentBusinessKeySuffix(",
	} {
		if strings.Contains(generalSrc, symbol) {
			t.Fatalf("source_backed_component_builders.go still owns connector-builder symbol %q", symbol)
		}
		if !strings.Contains(connectorSrc, symbol) {
			t.Fatalf("source_backed_connector_component_builders.go is missing connector-builder symbol %q", symbol)
		}
	}

	if !strings.Contains(generalSrc, "func attachSourceBackedComponentBuildHandlers(") {
		t.Fatal("source_backed_component_builders.go must still attach ComponentKind build handlers")
	}
}
