mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-08-21 14:46:58 +00:00
test(s3/versioning): read the whole version body instead of one Read (#10815)
A single Read on the response body can return the last bytes together with io.EOF, so asserting NoError on it fails even though the body is complete. Use io.ReadAll, like every other test in this package.
This commit is contained in:
@@ -3,6 +3,7 @@ package s3api
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -184,12 +185,11 @@ func TestVersioningPaginationOver1000Versions(t *testing.T) {
|
||||
})
|
||||
require.NoError(t, err, "Failed to get version at index %d", idx)
|
||||
|
||||
buf := make([]byte, len(expectedContent))
|
||||
_, err = getResp.Body.Read(buf)
|
||||
require.NoError(t, err)
|
||||
body, err := io.ReadAll(getResp.Body)
|
||||
getResp.Body.Close()
|
||||
require.NoError(t, err, "Failed to read version at index %d", idx)
|
||||
|
||||
assert.Equal(t, expectedContent, string(buf), "Content mismatch for version %d", idx+1)
|
||||
assert.Equal(t, expectedContent, string(body), "Content mismatch for version %d", idx+1)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user