mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 18:17:16 +01:00
s3api: drop error-body assertions from the HeadBucket test
HEAD responses carry no body since WriteResponse skips it, so the status code alone distinguishes a failed lookup from a missing bucket. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
82f0a82564
commit
3b5fcae07f
1 file changed
+4
-7
@@ -5,7 +5,6 @@ import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"path"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
@@ -56,19 +55,16 @@ func TestHeadBucketSeparatesLookupFailureFromMissingBucket(t *testing.T) {
|
||||
name string
|
||||
filer *fakeLookupFiler
|
||||
wantCode int
|
||||
wantBody string
|
||||
}{
|
||||
{
|
||||
name: "transient lookup failure",
|
||||
filer: &fakeLookupFiler{lookupErr: status.Error(codes.Internal, "filer store unavailable")},
|
||||
wantCode: http.StatusInternalServerError,
|
||||
wantBody: "<Code>InternalError</Code>",
|
||||
},
|
||||
{
|
||||
name: "missing bucket",
|
||||
filer: &fakeLookupFiler{},
|
||||
wantCode: http.StatusNotFound,
|
||||
wantBody: "<Code>NoSuchBucket</Code>",
|
||||
},
|
||||
{
|
||||
name: "existing bucket",
|
||||
@@ -86,10 +82,11 @@ func TestHeadBucketSeparatesLookupFailureFromMissingBucket(t *testing.T) {
|
||||
s3a.HeadBucketHandler(rr, req)
|
||||
|
||||
if rr.Code != tc.wantCode {
|
||||
t.Fatalf("status = %d, want %d: %s", rr.Code, tc.wantCode, rr.Body.String())
|
||||
t.Fatalf("status = %d, want %d", rr.Code, tc.wantCode)
|
||||
}
|
||||
if tc.wantBody != "" && !strings.Contains(rr.Body.String(), tc.wantBody) {
|
||||
t.Fatalf("body = %s, want %s", rr.Body.String(), tc.wantBody)
|
||||
// HEAD responses never carry a body; the status code is the whole answer.
|
||||
if rr.Body.Len() != 0 {
|
||||
t.Fatalf("HEAD response must not have a body, got %q", rr.Body.String())
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user