rc: fix tests after go1.23 upgrade

go1.23 adds a doctype to the HTML output when serving file listings.
This adapts the tests for that.
This commit is contained in:
Nick Craig-Wood 2024-07-19 09:43:51 +01:00
parent 485aa90d13
commit 3b51ad24b2

View File

@ -153,7 +153,9 @@ func testServer(t *testing.T, tests []testRun, opt *rc.Options) {
actualNormalized := normalizeJSON(t, string(body)) actualNormalized := normalizeJSON(t, string(body))
assert.Equal(t, expectedNormalized, actualNormalized, "Normalized JSON does not match") assert.Equal(t, expectedNormalized, actualNormalized, "Normalized JSON does not match")
} else if test.Contains == nil { } else if test.Contains == nil {
assert.Equal(t, test.Expected, string(body)) // go1.23 started putting an html wrapper
bodyNormalized := strings.TrimPrefix(string(body), "<!doctype html>\n<meta name=\"viewport\" content=\"width=device-width\">\n")
assert.Equal(t, test.Expected, bodyNormalized)
} else { } else {
assert.True(t, test.Contains.Match(body), fmt.Sprintf("body didn't match: %v: %v", test.Contains, string(body))) assert.True(t, test.Contains.Match(body), fmt.Sprintf("body didn't match: %v: %v", test.Contains, string(body)))
} }