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) err := tmpl.Execute(nil, nil)
if err == nil { if err == nil {
t.Error("expected error") t.Error("expected error")
} } else if !strings.Contains(err.Error(), "incomplete") {
if !strings.Contains(err.Error(), "incomplete") {
t.Errorf("expected error about incomplete template; got %s", err) t.Errorf("expected error about incomplete template; got %s", err)
} }
} }