Tests for options that cannot take effect, and entries that are not data

This commit is contained in:
M
2026-08-28 00:17:27 +02:00
committed by lilleman-tw
parent af09a86e71
commit 8d0393713c
2 changed files with 91 additions and 0 deletions
+25
View File
@@ -5,6 +5,7 @@ import (
"path/filepath"
"reflect"
"slices"
"strings"
"testing"
)
@@ -156,3 +157,27 @@ func TestListedPathsAllRender(t *testing.T) {
}
}
}
// TestHiddenEntriesAreSkipped keeps a data directory usable when it is also a
// checkout or an editor workspace: a dot-prefixed entry is not data, and a folder
// carrying no JSON never contributed a namespace, so neither may fail the load.
func TestHiddenEntriesAreSkipped(t *testing.T) {
dir := writeData(t, map[string]string{
"cat": `["V"]`,
".git/HEAD": `["ignored"]`,
".hidden": `["ignored"]`,
"empty.folder/doc": `["ignored"]`,
})
if err := os.Rename(filepath.Join(dir, "empty.folder", "doc.json"), filepath.Join(dir, "empty.folder", "doc.txt")); err != nil {
t.Fatal(err)
}
f := newFakes(t, dir, WithSeed(1))
if got := fake(t, f, "cat"); got != "V" {
t.Fatalf("cat = %q, want V", got)
}
for _, p := range f.List() {
if strings.HasPrefix(p, ".") || strings.Contains(p, "empty.folder") {
t.Errorf("List() advertises %q, which is not data", p)
}
}
}