package features

import (
	"path/filepath"
	"testing"
)

func TestDefaultPublicRepoCacheDirUsesMeshXDataRoot(t *testing.T) {
	repoRoot := t.TempDir()
	want := filepath.Join(repoRoot, ".data", "meshx", "public-repo-cache")
	if got := defaultPublicRepoCacheDir(repoRoot); filepath.Clean(got) != filepath.Clean(want) {
		t.Fatalf("path = %q, want %q", got, want)
	}
	if !shouldUseDefaultPublicRepoCacheDir("", repoRoot) {
		t.Fatal("empty path should use the default")
	}
	if !shouldUseDefaultPublicRepoCacheDir(want, repoRoot) {
		t.Fatal("legacy repo-local path should use the default")
	}
	if shouldUseDefaultPublicRepoCacheDir(filepath.Join(t.TempDir(), "custom-cache"), repoRoot) {
		t.Fatal("custom path should be preserved")
	}
}
