Test that a manifest's namespace mounts its source under a dot path, that each shipped module loads from data/<lowered namespace>, and that a load failure's note reaches Fake, FakeTemplate and FakeStruct once

This commit is contained in:
2026-10-11 12:15:41 +02:00
committed by Lillem4n
parent 165b67e843
commit 29a76d5d9a
11 changed files with 165 additions and 58 deletions
+13
View File
@@ -3,6 +3,8 @@ package fejkdata
import (
"errors"
"io/fs"
"os"
"path/filepath"
"strings"
"testing"
"testing/fstest"
@@ -35,6 +37,17 @@ func newGeneratorN(t *testing.T, dirs []string, opts ...Option) *Generator {
return f
}
// newBareModule loads the shipped module in data/<module> without its manifest, so its
// categories sit at the root, failing on error.
func newBareModule(t *testing.T, module string, opts ...Option) *Generator {
t.Helper()
f, err := New(append([]Option{WithDataFS(withoutManifest{os.DirFS(filepath.Join("data", module))})}, opts...)...)
if err != nil {
t.Fatalf("New(%s without its manifest): %v", module, err)
}
return f
}
// fake generates a value, failing the test on error.
func fake(t *testing.T, f *Generator, path string) string {
t.Helper()