Test that a pin clash below a nested template names the root's route

This commit is contained in:
2026-09-29 20:18:13 +02:00
committed by Lillem4n
parent 73fa013011
commit 6fdd8bd09b
+8
View File
@@ -140,6 +140,7 @@ func TestReadSurveyWalksACellByEveryRoute(t *testing.T) {
func TestReadSurveyReportsAPinClashAsAnError(t *testing.T) {
fsys := fstest.MapFS{
"r.json": {Data: []byte(`"{/y[a].v}"`)},
"n.json": {Data: []byte(`{"format":"{f}","f":"{/y[a].v}"}`)},
"x.json": {Data: []byte(`{"format":"{v}","rows":"x.tsv","key":"code"}`)},
"x.tsv": {Data: []byte("code\tv\n1\tb\n2\tc\n")},
"y.json": {Data: []byte(`{"format":"{v}","rows":"y.tsv","key":"code","parent":"x"}`)},
@@ -159,4 +160,11 @@ func TestReadSurveyReportsAPinClashAsAnError(t *testing.T) {
if err := surveyRender(r).check(); err == nil || !strings.Contains(err.Error(), "two rows of") {
t.Errorf("check = %v, want y[a]'s row of x clashing with x[2] named, whatever order the fences run in", err)
}
n, isTemplate := g.children["n"].(*template)
if !isTemplate {
t.Fatalf("n is a %T, want a template", g.children["n"])
}
if err := surveyRender(n).check(); err == nil || !strings.HasPrefix(err.Error(), "{f} with {/x[2].v}: x[1] and x[2] are two rows of x") {
t.Errorf("check = %v, want the clash below {f} named by the route the root reaches it by", err)
}
}