forked from TrueCloudLab/frostfs-s3-gw
[#474] Use appropriate null version during listing
Signed-off-by: Denis Kirillov <denis@nspcc.ru>
This commit is contained in:
parent
c8e8ba9f6a
commit
a02900a4f7
9 changed files with 81 additions and 22 deletions
|
@ -1,8 +1,12 @@
|
|||
package handler
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/nspcc-dev/neofs-s3-gw/api/layer"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
|
@ -35,3 +39,37 @@ func TestParseContinuationToken(t *testing.T) {
|
|||
require.Equal(t, tokenStr, token)
|
||||
})
|
||||
}
|
||||
|
||||
func TestListObjectNullVersions(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
hc := prepareHandlerContext(t)
|
||||
|
||||
bktName := "bucket-versioning-enabled"
|
||||
createTestBucket(ctx, t, hc, bktName)
|
||||
|
||||
objName := "object"
|
||||
|
||||
body := bytes.NewReader([]byte("content"))
|
||||
w, r := prepareTestPayloadRequest(bktName, objName, body)
|
||||
hc.Handler().PutObjectHandler(w, r)
|
||||
assertStatus(t, w, http.StatusOK)
|
||||
|
||||
versioning := &VersioningConfiguration{Status: "Enabled"}
|
||||
w, r = prepareTestRequest(t, bktName, objName, versioning)
|
||||
hc.Handler().PutBucketVersioningHandler(w, r)
|
||||
assertStatus(t, w, http.StatusOK)
|
||||
|
||||
body2 := bytes.NewReader([]byte("content2"))
|
||||
w, r = prepareTestPayloadRequest(bktName, objName, body2)
|
||||
hc.Handler().PutObjectHandler(w, r)
|
||||
assertStatus(t, w, http.StatusOK)
|
||||
|
||||
w, r = prepareTestRequest(t, bktName, objName, nil)
|
||||
hc.Handler().ListBucketObjectVersionsHandler(w, r)
|
||||
|
||||
result := &ListObjectsVersionsResponse{}
|
||||
parseTestResponse(t, w, result)
|
||||
|
||||
require.Len(t, result.Version, 2)
|
||||
require.Equal(t, layer.UnversionedObjectVersionID, result.Version[1].VersionID)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue