templates: fix crash in improperly defined templates (#12483)

This commit is contained in:
Patrick Devine
2025-10-02 17:25:55 -07:00
committed by GitHub
parent 0bda72892c
commit 1ed2881ef0
3 changed files with 65 additions and 20 deletions

View File

@@ -192,7 +192,11 @@ func TestParse(t *testing.T) {
t.Fatal(err)
}
if diff := cmp.Diff(tmpl.Vars(), tt.vars); diff != "" {
v, err := tmpl.Vars()
if err != nil {
t.Fatal(err)
}
if diff := cmp.Diff(v, tt.vars); diff != "" {
t.Errorf("mismatch (-got +want):\n%s", diff)
}
})