lib/http: fix tests after go1.23 update

go1.22 output the Content-Length on a bad Range request on a file but
go1.23 doesn't - adapt the tests accordingly.
This commit is contained in:
Nick Craig-Wood 2024-07-19 09:48:22 +01:00
parent 3b51ad24b2
commit d149d1ec3e

View File

@ -76,7 +76,9 @@ func TestObjectBadRange(t *testing.T) {
Object(w, r, o) Object(w, r, o)
resp := w.Result() resp := w.Result()
assert.Equal(t, http.StatusBadRequest, resp.StatusCode) assert.Equal(t, http.StatusBadRequest, resp.StatusCode)
assert.Equal(t, "10", resp.Header.Get("Content-Length")) if contentLength := resp.Header.Get("Content-Length"); contentLength != "" {
assert.Equal(t, "10", contentLength)
}
body, _ := io.ReadAll(resp.Body) body, _ := io.ReadAll(resp.Body)
assert.Equal(t, "Bad Request\n", string(body)) assert.Equal(t, "Bad Request\n", string(body))
} }