mirror of
https://github.com/golang/go
synced 2024-11-23 17:20:02 -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:
parent
ad6e2e8fe1
commit
20501470bb
@ -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)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user