package dialectsfcrm

import (
	"os/exec"
	"strings"
	"testing"
)

// TestRuntimeClientsStayAboveWire pins the L1/L0 release boundary for every
// dormant sfcrm Runtime consumer: sfcrm owns product projection from neutral
// semantic contracts, while L0 api-host owns generated gRPC invocation policy.
func TestRuntimeClientsStayAboveWire(t *testing.T) {
	out, err := exec.Command("go", "list", "-deps", ".").CombinedOutput()
	if err != nil {
		t.Fatalf("list sfcrm runtime dependencies: %v\n%s", err, out)
	}
	for _, dependency := range strings.Fields(string(out)) {
		for _, forbidden := range []string{
			"github.com/pingcap-inc/nexuscrm-api-host",
			"github.com/pingcap-inc/nexuscrm-contract/wire-go",
			"google.golang.org/grpc",
		} {
			if dependency == forbidden || strings.HasPrefix(dependency, forbidden+"/") {
				t.Errorf("sfcrm production projection depends on transport owner %q", dependency)
			}
		}
	}
}
