From d149d1ec3ec3977f272483143861e62c44b48f36 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Fri, 19 Jul 2024 09:48:22 +0100 Subject: [PATCH] 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. --- lib/http/serve/serve_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/http/serve/serve_test.go b/lib/http/serve/serve_test.go index dc9098428..79daf773e 100644 --- a/lib/http/serve/serve_test.go +++ b/lib/http/serve/serve_test.go @@ -76,7 +76,9 @@ func TestObjectBadRange(t *testing.T) { Object(w, r, o) resp := w.Result() 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) assert.Equal(t, "Bad Request\n", string(body)) }