Commit aef1a7e1 authored by Marat Khabibullin's avatar Marat Khabibullin Committed by Bryan C. Mills

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).

Updates #30208

Change-Id: I6f7a8609f2453f622a1fa94a50c99d2e04d5fbcd
GitHub-Last-Rev: 3a5d9b1e9e202327af17cc1b93bfa69f6701af84
GitHub-Pull-Request: golang/go#30215
Reviewed-on: https://go-review.googlesource.com/c/162477Reviewed-by: default avatarBryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent c05f2b48
......@@ -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)
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment