Test that the shipped data loads from a Go package per module, that a bare New fails naming WithDataFS, and that a read nothing provides names the modules its reader's manifest reads

This commit is contained in:
2026-10-10 13:08:01 +02:00
committed by Lillem4n
parent bf1becbb59
commit 3368f085fd
26 changed files with 471 additions and 188 deletions
+2 -2
View File
@@ -130,7 +130,7 @@ func TestPathKeyIsUnambiguous(t *testing.T) {
dir := writeData(t, map[string]string{
"cat": `[{"format":"{a.b}","a.b":"1"},{"format":"{a}","a":{"format":"{b}","b":"2"}}]`,
})
_, err := New(WithoutShippedData(), WithDataPath(dir))
_, err := New(WithDataPath(dir))
if err == nil || !strings.Contains(err.Error(), `field "a.b" contains "."`) {
t.Fatalf("New = %v, want the dotted field name rejected", err)
}
@@ -150,7 +150,7 @@ func TestPathKeyIsUnambiguous(t *testing.T) {
// single-variant choice always draws the same item, so it needs no every-variant
// guard and the error can name the field that is missing.
func TestMissingFieldNamesItself(t *testing.T) {
f := newGenerator(t, "data", WithSeed(1))
f := shipped(t, WithSeed(1))
_, err := f.Fake("sv_SE.person.typo")
if err == nil || !strings.Contains(err.Error(), `no field "typo"`) {
t.Errorf("Fake(person.typo) = %v, want it to name the missing field", err)