1
0
mirror of https://github.com/golang/go synced 2024-11-23 15:00:03 -07:00

html/template: prevent test from failing with nil pointer dereference

The variable err could have nil value when we call err.Error(), because after we check it for nil above we continue the test (t.Errorf doesn't stop the test execution).
This commit is contained in:
Marat Khabibullin 2019-02-13 18:00:10 +03:00
parent ad6e2e8fe1
commit 20501470bb

View File

@ -1869,8 +1869,7 @@ func TestErrorOnUndefined(t *testing.T) {
err := tmpl.Execute(nil, nil)
if err == nil {
t.Error("expected error")
}
if !strings.Contains(err.Error(), "incomplete") {
} else if !strings.Contains(err.Error(), "incomplete") {
t.Errorf("expected error about incomplete template; got %s", err)
}
}