]> Cypherpunks repositories - gostls13.git/commitdiff
html/template: prevent test from failing with nil pointer dereference
authorMarat Khabibullin <marat.khabibullin@jetbrains.com>
Wed, 13 Feb 2019 19:20:50 +0000 (19:20 +0000)
committerBryan C. Mills <bcmills@google.com>
Sat, 2 Mar 2019 01:53:40 +0000 (01:53 +0000)
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>

src/html/template/escape_test.go

index e6c12a8a254b2bded9e565c213458851b617e4c2..e72a9ba11fe281bc2a2e3d82434c17bf6c442696 100644 (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)
        }
 }