Skip to content

Commit 213092a

Browse files
dmitshurgopherbot
authored andcommitted
godev/internal/content: expect one less newline for Go 1.23
The /index.html and /index test cases happen to be testing the exact whitespace produced by net/http's redirect body text, which lost one of its two newlines in CL 562356. Maybe these tests shouldn't report whitespace differences at all, but they do and such differences will be fairly rare. Update the test case for Go 1.23 onwards, with a small adjustment to keep it working for older supported versions too. Change-Id: Ia304cdb9f399f7dcb969066bf9c1ec6424b002ca Reviewed-on: https://go-review.googlesource.com/c/telemetry/+/563357 Auto-Submit: Dmitri Shuralyov <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> Reviewed-by: Robert Findley <[email protected]>
1 parent aa1e196 commit 213092a

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

godev/internal/content/content_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package content
66

77
import (
88
"errors"
9+
"go/build"
910
"io/fs"
1011
"net/http"
1112
"net/http/httptest"
@@ -111,6 +112,10 @@ func TestServer_ServeHTTP(t *testing.T) {
111112
t.Fatal(err)
112113
}
113114
wantBody := string(data)
115+
if tt.wantCode == http.StatusMovedPermanently && len(build.Default.ReleaseTags) < 23 {
116+
// Prior to Go 1.23, net/http generated an extra newline in its redirect text (CL 562356).
117+
wantBody += "\n"
118+
}
114119
if diff := cmp.Diff(wantBody, got); diff != "" {
115120
t.Errorf("GET %s response body mismatch (-want, +got):\n%s", tt.path, diff)
116121
}
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
<a href="/index">Moved Permanently</a>.
2-
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
<a href="/">Moved Permanently</a>.
2-

0 commit comments

Comments
 (0)