aboutsummaryrefslogtreecommitdiff
path: root/src/html
diff options
context:
space:
mode:
authorMarat Khabibullin <marat.khabibullin@jetbrains.com>2019-02-13 19:20:50 +0000
committerBryan C. Mills <bcmills@google.com>2019-03-02 01:53:40 +0000
commitaef1a7e19251dee75c30c5fc0828ac5cb9722035 (patch)
tree0cf33c54706e7ec61cf4033402aab179aa613d70 /src/html
parentc05f2b4869e6ac581e85638f9dc3dba16d9ba2f4 (diff)
downloadgo-aef1a7e19251dee75c30c5fc0828ac5cb9722035.tar.gz
go-aef1a7e19251dee75c30c5fc0828ac5cb9722035.zip
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/162477 Reviewed-by: Bryan C. Mills <bcmills@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/html')
-rw-r--r--src/html/template/escape_test.go3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/html/template/escape_test.go b/src/html/template/escape_test.go
index e6c12a8a25..e72a9ba11f 100644
--- a/src/html/template/escape_test.go
+++ b/src/html/template/escape_test.go
@@ -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)
}
}