Pin each overlap refusal to its own wording
This commit is contained in:
+5
-5
@@ -56,7 +56,7 @@ func TestRenderingALevelAndReadingIntoItIsRejected(t *testing.T) {
|
||||
t.Errorf("%s: New = nil error, want the overlapping tokens rejected", name)
|
||||
continue
|
||||
}
|
||||
if !strings.HasPrefix(err.Error(), "fejkdata: cat: ") || !strings.Contains(err.Error(), "reads a path into") {
|
||||
if !strings.HasPrefix(err.Error(), "fejkdata: cat: ") || !strings.Contains(err.Error(), "renders a level that") {
|
||||
t.Errorf("%s: New = %v, want it to name the category path and the overlap", name, err)
|
||||
}
|
||||
}
|
||||
@@ -76,7 +76,7 @@ func TestCalcOperandNamingAHeldLevelIsRejected(t *testing.T) {
|
||||
"cat": `{"format":"{item.price}|{calc(item * 1)}","item":[` +
|
||||
`{"format":"{price}","price":"10"},{"format":"{price}","price":"20"}]}`,
|
||||
})))
|
||||
if err == nil || !strings.Contains(err.Error(), "reads a path into") {
|
||||
if err == nil || !strings.Contains(err.Error(), "renders a level that") {
|
||||
t.Fatalf("New = %v, want the calc operand rejected as an overlap", err)
|
||||
}
|
||||
// Arithmetic over fields no path names is untouched.
|
||||
@@ -113,7 +113,7 @@ func TestReferenceNamingAHeldLevelIsRejected(t *testing.T) {
|
||||
}
|
||||
for name, files := range rejected {
|
||||
_, err := New(WithoutShippedData(), WithDataPath(writeData(t, files)))
|
||||
if err == nil || !strings.Contains(err.Error(), "reads a path into") {
|
||||
if err == nil || !strings.Contains(err.Error(), "by a second route") {
|
||||
t.Errorf("%s: New = %v, want the reference rejected as an overlap", name, err)
|
||||
}
|
||||
}
|
||||
@@ -147,7 +147,7 @@ func TestALevelRenderedOnlyByAPathTokenIsHeld(t *testing.T) {
|
||||
`"q":{"format":"{x}","x":["1","2"]}}`,
|
||||
"hop": `"{/thing.q}"`,
|
||||
})))
|
||||
if err == nil || !strings.Contains(err.Error(), "reads a path into") {
|
||||
if err == nil || !strings.Contains(err.Error(), "by a second route") {
|
||||
t.Fatalf("New = %v, want the second route to q rejected", err)
|
||||
}
|
||||
}
|
||||
@@ -308,7 +308,7 @@ func TestAPathReachesEveryVariantItMightDraw(t *testing.T) {
|
||||
`"q":{"format":"{y}","y":["1","2"]}}`,
|
||||
"hop": `"{/cat.q}"`,
|
||||
},
|
||||
"reads a path into",
|
||||
"by a second route",
|
||||
},
|
||||
}
|
||||
for name, c := range rejected {
|
||||
|
||||
+2
-2
@@ -108,8 +108,8 @@ func TestFakeTemplateErrors(t *testing.T) {
|
||||
{`name: {/no.such.path}`, "no entry"},
|
||||
{`name: {..nope}`, "write {/nope}"},
|
||||
{`{"format":"x"}`, "is a string"},
|
||||
{`{/misc.territory} {/misc.territory.alpha2}`, "renders a level that {/misc.territory.alpha2} reads a path into; name the fields you want instead, or draw them apart with a drawGroup"},
|
||||
{`{"format":"{/misc.territory.alpha2} {x}","x":"{/misc.territory}"}`, "reads a path into"},
|
||||
{`{/misc.territory} {/misc.territory.alpha2}`, "reads whole the reference draw that {/misc.territory.alpha2} reads a path into; name the fields you want instead, or draw them apart with a drawGroup"},
|
||||
{`{"format":"{/misc.territory.alpha2} {x}","x":"{/misc.territory}"}`, "reads whole the reference draw"},
|
||||
{`{"format":"{/misc.territory.alpha2}","drawGroup":"g"}`, "nothing can reference"},
|
||||
} {
|
||||
_, err := f.FakeTemplate(c.input)
|
||||
|
||||
+2
-2
@@ -220,7 +220,7 @@ func TestRecordRejectsOverlappingReferenceColumns(t *testing.T) {
|
||||
{"a column reaching back through another category", `{"format":"","whole":"{/mid}","inner":"{/cat.a.b}"}`},
|
||||
} {
|
||||
_, err := New(WithoutShippedData(), WithDataPath(writeData(t, map[string]string{"cat": cat, "mid": mid, "row": c.row})))
|
||||
if err == nil || !strings.Contains(err.Error(), "reads a path into") {
|
||||
if err == nil || !strings.Contains(err.Error(), "reads whole the reference draw") {
|
||||
t.Errorf("%s: New = %v, want the overlap refused at load, the way one format is", c.name, err)
|
||||
continue
|
||||
}
|
||||
@@ -236,7 +236,7 @@ func TestInlineRecordRejectsOverlappingColumns(t *testing.T) {
|
||||
})
|
||||
f := newGenerator(t, dir, WithSeed(1))
|
||||
_, err := f.FakeRecordTemplate(`{"format":"","whole":"{/cat.a}","inner":"{/cat.a.b}"}`)
|
||||
if err == nil || !strings.Contains(err.Error(), "reads a path into") {
|
||||
if err == nil || !strings.Contains(err.Error(), "reads whole the reference draw") {
|
||||
t.Fatalf("inline record over an overlapping pair = %v, want the inline entry point to refuse it too", err)
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -271,7 +271,7 @@ func TestReferenceOverlapIsRejected(t *testing.T) {
|
||||
"a bare reference beside a path into what it never renders": `{"format":"{a} {b}","a":"{/cat}","b":"{/cat.p.first}"}`,
|
||||
} {
|
||||
_, err := New(WithoutShippedData(), WithDataPath(writeData(t, map[string]string{"cat": cat, "row": row})))
|
||||
if err == nil || !strings.Contains(err.Error(), "reads a path into") {
|
||||
if err == nil || !strings.Contains(err.Error(), "reads whole the reference draw") {
|
||||
t.Errorf("%s: New = %v, want the overlap rejected", name, err)
|
||||
}
|
||||
}
|
||||
@@ -280,7 +280,7 @@ func TestReferenceOverlapIsRejected(t *testing.T) {
|
||||
if _, err := New(WithoutShippedData(), WithDataPath(writeData(t, map[string]string{
|
||||
"row": `{"format":"{p.first} {/hop}","p":[{"format":"{first}","first":"A","last":"1"},{"format":"{first}","first":"B","last":"2"}]}`,
|
||||
"hop": `"{/row.p.last}"`,
|
||||
}))); err == nil || !strings.Contains(err.Error(), "reads a path into") {
|
||||
}))); err == nil || !strings.Contains(err.Error(), "by a second route") {
|
||||
t.Errorf("New = %v, want a sibling path beside a reference into it rejected", err)
|
||||
}
|
||||
if _, err := New(WithoutShippedData(), WithDataPath(writeData(t, map[string]string{
|
||||
@@ -413,7 +413,7 @@ func TestSpellingsOfOneReferenceAreOneLevel(t *testing.T) {
|
||||
"sv_SE/person": person,
|
||||
"sv_SE/mail": `"{.person} <{/sv_SE.person.first}>"`,
|
||||
})))
|
||||
if err == nil || !strings.Contains(err.Error(), "reads a path into") || !strings.Contains(err.Error(), "{.person}") {
|
||||
if err == nil || !strings.Contains(err.Error(), "reads whole the reference draw") || !strings.Contains(err.Error(), "{.person}") {
|
||||
t.Errorf("New = %v, want the bare spelling rejected beside the path spelling", err)
|
||||
}
|
||||
dir := writeData(t, map[string]string{
|
||||
|
||||
+1
-1
@@ -296,7 +296,7 @@ func TestFakeStructErrors(t *testing.T) {
|
||||
{&struct {
|
||||
A string `fake:"trip.leg"`
|
||||
B string `fake:"trip.leg.to"`
|
||||
}{}, "reads a path into"},
|
||||
}{}, "reads whole the reference draw"},
|
||||
{&struct {
|
||||
Trip struct {
|
||||
A int `fake:"{digits(3)}"`
|
||||
|
||||
+2
-2
@@ -367,7 +367,7 @@ func TestTableSelectorInAReference(t *testing.T) {
|
||||
|
||||
func TestTableSelectionFences(t *testing.T) {
|
||||
rejected := map[string]struct{ json, want string }{
|
||||
"bare beside a path": {`"{/region} {/region.name}"`, "reads a path into"},
|
||||
"bare beside a path": {`"{/region} {/region.name}"`, "reads whole the reference draw"},
|
||||
"bare beside a linked path": {`"{/region} {/locality.name}"`, "drawGroup"},
|
||||
"selected beside unselected": {`"{/region[12].municipality.name} {/municipality.code}"`, "{/region[12].municipality.code}"},
|
||||
"relative selected beside unselected": {`"{.region[12].municipality.name} {.municipality.code}"`, "{.region[12].municipality.code}"},
|
||||
@@ -1120,7 +1120,7 @@ func TestCellReadsMeetWhereTheRenderPairsTheRows(t *testing.T) {
|
||||
"region.json": `{"format":"{name}={note}","rows":"region.tsv","key":"code","name":"name","weight":"population"}`,
|
||||
"x.json": `"{/region}|{/municipality}"`,
|
||||
})
|
||||
if _, err := New(WithoutShippedData(), WithDataPath(writeFiles(t, whole)), WithSeed(1)); err == nil || !strings.Contains(err.Error(), "reads a path into") {
|
||||
if _, err := New(WithoutShippedData(), WithDataPath(writeFiles(t, whole)), WithSeed(1)); err == nil || !strings.Contains(err.Error(), "reads whole the reference draw") {
|
||||
t.Fatalf("New = %v, want the two drawn rows held to one draw of addr", err)
|
||||
}
|
||||
nested := with(whole, map[string]string{
|
||||
|
||||
Reference in New Issue
Block a user