[#409] Update SDK

Signed-off-by: Denis Kirillov <denis@nspcc.ru>
This commit is contained in:
Denis Kirillov 2022-04-25 12:57:58 +03:00 committed by Kira
parent 6e91074b50
commit e3c16a32dd
33 changed files with 332 additions and 263 deletions

View file

@ -7,10 +7,11 @@ import (
"time"
"github.com/nspcc-dev/neofs-s3-gw/api/data"
"github.com/nspcc-dev/neofs-sdk-go/checksum"
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
"github.com/nspcc-dev/neofs-sdk-go/object"
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
"github.com/nspcc-dev/neofs-sdk-go/owner"
"github.com/nspcc-dev/neofs-sdk-go/user"
"github.com/stretchr/testify/require"
)
@ -35,9 +36,9 @@ func newTestObject(id *oid.ID, bkt *data.BucketInfo, name string) *object.Object
contentType.SetValue(defaultTestContentType)
obj := object.New()
obj.SetID(id)
obj.SetID(*id)
obj.SetOwnerID(bkt.Owner)
obj.SetContainerID(bkt.CID)
obj.SetContainerID(*bkt.CID)
obj.SetPayload(defaultTestPayload)
obj.SetAttributes(*filename, *created, *contentType)
obj.SetPayloadSize(uint64(defaultTestPayloadLength))
@ -46,6 +47,7 @@ func newTestObject(id *oid.ID, bkt *data.BucketInfo, name string) *object.Object
}
func newTestInfo(oid *oid.ID, bkt *data.BucketInfo, name string, isDir bool) *data.ObjectInfo {
var hashSum checksum.Checksum
info := &data.ObjectInfo{
ID: oid,
Name: name,
@ -56,6 +58,7 @@ func newTestInfo(oid *oid.ID, bkt *data.BucketInfo, name string, isDir bool) *da
Created: time.Unix(defaultTestCreated.Unix(), 0),
Owner: bkt.Owner,
Headers: make(map[string]string),
HashSum: hashSum.String(),
}
if isDir {
@ -69,14 +72,14 @@ func newTestInfo(oid *oid.ID, bkt *data.BucketInfo, name string, isDir bool) *da
}
func Test_objectInfoFromMeta(t *testing.T) {
uid := owner.NewID()
id := oid.NewID()
containerID := cid.New()
var uid user.ID
var id oid.ID
var containerID cid.ID
bkt := &data.BucketInfo{
Name: "test-container",
CID: containerID,
Owner: uid,
CID: &containerID,
Owner: &uid,
Created: time.Now(),
}
@ -89,66 +92,66 @@ func Test_objectInfoFromMeta(t *testing.T) {
}{
{
name: "small.jpg",
result: newTestInfo(id, bkt, "small.jpg", false),
object: newTestObject(id, bkt, "small.jpg"),
result: newTestInfo(&id, bkt, "small.jpg", false),
object: newTestObject(&id, bkt, "small.jpg"),
},
{
name: "small.jpg not matched prefix",
prefix: "big",
result: nil,
object: newTestObject(id, bkt, "small.jpg"),
object: newTestObject(&id, bkt, "small.jpg"),
},
{
name: "small.jpg delimiter",
delimiter: "/",
result: newTestInfo(id, bkt, "small.jpg", false),
object: newTestObject(id, bkt, "small.jpg"),
result: newTestInfo(&id, bkt, "small.jpg", false),
object: newTestObject(&id, bkt, "small.jpg"),
},
{
name: "test/small.jpg",
result: newTestInfo(id, bkt, "test/small.jpg", false),
object: newTestObject(id, bkt, "test/small.jpg"),
result: newTestInfo(&id, bkt, "test/small.jpg", false),
object: newTestObject(&id, bkt, "test/small.jpg"),
},
{
name: "test/small.jpg with prefix and delimiter",
prefix: "test/",
delimiter: "/",
result: newTestInfo(id, bkt, "test/small.jpg", false),
object: newTestObject(id, bkt, "test/small.jpg"),
result: newTestInfo(&id, bkt, "test/small.jpg", false),
object: newTestObject(&id, bkt, "test/small.jpg"),
},
{
name: "a/b/small.jpg",
prefix: "a",
result: newTestInfo(id, bkt, "a/b/small.jpg", false),
object: newTestObject(id, bkt, "a/b/small.jpg"),
result: newTestInfo(&id, bkt, "a/b/small.jpg", false),
object: newTestObject(&id, bkt, "a/b/small.jpg"),
},
{
name: "a/b/small.jpg",
prefix: "a/",
delimiter: "/",
result: newTestInfo(id, bkt, "a/b/", true),
object: newTestObject(id, bkt, "a/b/small.jpg"),
result: newTestInfo(&id, bkt, "a/b/", true),
object: newTestObject(&id, bkt, "a/b/small.jpg"),
},
{
name: "a/b/c/small.jpg",
prefix: "a/",
delimiter: "/",
result: newTestInfo(id, bkt, "a/b/", true),
object: newTestObject(id, bkt, "a/b/c/small.jpg"),
result: newTestInfo(&id, bkt, "a/b/", true),
object: newTestObject(&id, bkt, "a/b/c/small.jpg"),
},
{
name: "a/b/c/small.jpg",
prefix: "a/b/c/s",
delimiter: "/",
result: newTestInfo(id, bkt, "a/b/c/small.jpg", false),
object: newTestObject(id, bkt, "a/b/c/small.jpg"),
result: newTestInfo(&id, bkt, "a/b/c/small.jpg", false),
object: newTestObject(&id, bkt, "a/b/c/small.jpg"),
},
{
name: "a/b/c/big.jpg",
prefix: "a/b/",
delimiter: "/",
result: newTestInfo(id, bkt, "a/b/c/", true),
object: newTestObject(id, bkt, "a/b/c/big.jpg"),
result: newTestInfo(&id, bkt, "a/b/c/", true),
object: newTestObject(&id, bkt, "a/b/c/big.jpg"),
},
}