Skip to content

Commit ed4febb

Browse files
committed
tests: Don't panic if template parsing fails
1 parent f072793 commit ed4febb

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

internal/template/template_test.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,13 @@ func (tests templateTestList) run(t *testing.T) {
2121
test := test
2222
t.Run(strconv.Itoa(n), func(t *testing.T) {
2323
t.Parallel()
24-
tmpl := template.Must(newTemplate("testTemplate").Parse(test.tmpl))
24+
tmpl, err := newTemplate("testTemplate").Parse(test.tmpl)
25+
if err != nil {
26+
t.Fatalf("Template parse failed: %v", err)
27+
}
2528

2629
var b bytes.Buffer
27-
err := tmpl.ExecuteTemplate(&b, "testTemplate", test.context)
30+
err = tmpl.ExecuteTemplate(&b, "testTemplate", test.context)
2831
if err != nil {
2932
t.Fatalf("Error executing template: %v", err)
3033
}

0 commit comments

Comments
 (0)