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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user