Tests for options that cannot take effect, and entries that are not data
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user