package dialect_test

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

// TestContractIsGinBackendAndHTTPFree is the boundary proof for #1743: the gin-free
// dialect contract must be implementable by an external app pack that depends ONLY
// on github.com/nexuscrm/shared. If this package ever transitively pulls gin,
// net/http, the backend module, or pkg/apierr, the "gin-free codec" seam
// (seam-1 D-2) is broken — external dialects would be forced onto the backend
// transport framework and the later codec split would become a breaking redesign.
//
// This guards the door package itself; it does NOT rely on a downstream toy's seal.
func TestContractIsGinBackendAndHTTPFree(t *testing.T) {
	out, err := exec.Command("go", "list", "-deps", ".").CombinedOutput()
	if err != nil {
		t.Fatalf("go list -deps .: %v\n%s", err, out)
	}
	forbidden := []string{
		"github.com/nexuscrm/backend", // backend module (covers pkg/apierr et al.)
		"github.com/gin-gonic/gin",    // transport framework
		"net/http",                    // transport
	}
	for _, dep := range strings.Fields(string(out)) {
		for _, bad := range forbidden {
			if dep == bad || strings.HasPrefix(dep, bad+"/") {
				t.Errorf("gin-free dialect contract pulls forbidden dependency %q", dep)
			}
		}
	}
}
