package connector_inbound

import (
	"os"
	"path/filepath"
	"regexp"
	"strings"
	"testing"
)

func TestInboundProductionIsProviderNeutral(t *testing.T) {
	forbidden := []string{"hubspot", "linear", "slack", "stripe"}
	pattern := regexp.MustCompile("(?i)(" + strings.Join(forbidden, "|") + ")")

	entries, err := os.ReadDir(".")
	if err != nil {
		t.Fatalf("read connector inbound package: %v", err)
	}
	for _, entry := range entries {
		if entry.IsDir() || !strings.HasSuffix(entry.Name(), ".go") || strings.HasSuffix(entry.Name(), "_test.go") {
			continue
		}
		content, err := os.ReadFile(filepath.Clean(entry.Name()))
		if err != nil {
			t.Fatalf("read %s: %v", entry.Name(), err)
		}
		if match := pattern.Find(content); match != nil {
			t.Errorf("provider name %q found in production file %s", match, entry.Name())
		}
	}
}
