2021-11-08 10:04:45 +00:00
|
|
|
package objecttest
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/google/uuid"
|
2021-11-08 10:04:45 +00:00
|
|
|
checksumtest "github.com/nspcc-dev/neofs-sdk-go/checksum/test"
|
2021-11-08 10:04:45 +00:00
|
|
|
cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test"
|
|
|
|
"github.com/nspcc-dev/neofs-sdk-go/object"
|
2022-01-25 16:20:32 +00:00
|
|
|
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
|
2022-02-01 10:15:12 +00:00
|
|
|
oidtest "github.com/nspcc-dev/neofs-sdk-go/object/id/test"
|
2021-11-08 10:04:45 +00:00
|
|
|
ownertest "github.com/nspcc-dev/neofs-sdk-go/owner/test"
|
|
|
|
sessiontest "github.com/nspcc-dev/neofs-sdk-go/session/test"
|
|
|
|
"github.com/nspcc-dev/neofs-sdk-go/version"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Range returns random object.Range.
|
|
|
|
func Range() *object.Range {
|
|
|
|
x := object.NewRange()
|
|
|
|
|
|
|
|
x.SetOffset(1024)
|
|
|
|
x.SetLength(2048)
|
|
|
|
|
|
|
|
return x
|
|
|
|
}
|
|
|
|
|
|
|
|
// Attribute returns random object.Attribute.
|
|
|
|
func Attribute() *object.Attribute {
|
|
|
|
x := object.NewAttribute()
|
|
|
|
|
|
|
|
x.SetKey("key")
|
|
|
|
x.SetValue("value")
|
|
|
|
|
|
|
|
return x
|
|
|
|
}
|
|
|
|
|
|
|
|
// SplitID returns random object.SplitID.
|
|
|
|
func SplitID() *object.SplitID {
|
|
|
|
x := object.NewSplitID()
|
|
|
|
|
|
|
|
x.SetUUID(uuid.New())
|
|
|
|
|
|
|
|
return x
|
|
|
|
}
|
|
|
|
|
2022-03-03 11:48:55 +00:00
|
|
|
func generate(withParent bool) *object.Object {
|
|
|
|
x := object.New()
|
2022-03-23 15:35:44 +00:00
|
|
|
ver := version.Current()
|
2021-11-08 10:04:45 +00:00
|
|
|
|
2022-02-01 10:15:12 +00:00
|
|
|
x.SetID(oidtest.ID())
|
2021-11-12 11:19:16 +00:00
|
|
|
x.SetSessionToken(sessiontest.Token())
|
2021-11-08 10:04:45 +00:00
|
|
|
x.SetPayload([]byte{1, 2, 3})
|
2021-11-12 11:19:16 +00:00
|
|
|
x.SetOwnerID(ownertest.ID())
|
|
|
|
x.SetContainerID(cidtest.ID())
|
2021-11-08 10:04:45 +00:00
|
|
|
x.SetType(object.TypeTombstone)
|
2022-03-23 15:35:44 +00:00
|
|
|
x.SetVersion(&ver)
|
2021-11-08 10:04:45 +00:00
|
|
|
x.SetPayloadSize(111)
|
|
|
|
x.SetCreationEpoch(222)
|
2022-02-01 10:15:12 +00:00
|
|
|
x.SetPreviousID(oidtest.ID())
|
|
|
|
x.SetParentID(oidtest.ID())
|
2022-04-11 16:25:14 +00:00
|
|
|
x.SetChildren(oidtest.ID(), oidtest.ID())
|
2022-03-11 09:00:54 +00:00
|
|
|
x.SetAttributes(*Attribute(), *Attribute())
|
2021-11-08 10:04:45 +00:00
|
|
|
x.SetSplitID(SplitID())
|
2021-11-08 10:04:45 +00:00
|
|
|
x.SetPayloadChecksum(checksumtest.Checksum())
|
|
|
|
x.SetPayloadHomomorphicHash(checksumtest.Checksum())
|
2021-11-08 10:04:45 +00:00
|
|
|
|
|
|
|
if withParent {
|
2022-03-03 11:48:55 +00:00
|
|
|
x.SetParent(generate(false))
|
2021-11-08 10:04:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return x
|
|
|
|
}
|
|
|
|
|
2022-03-03 11:48:55 +00:00
|
|
|
// Raw returns random object.Object.
|
|
|
|
// Deprecated: (v1.0.0) use Object instead.
|
|
|
|
func Raw() *object.Object {
|
|
|
|
return Object()
|
2021-11-08 10:04:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Object returns random object.Object.
|
|
|
|
func Object() *object.Object {
|
2022-03-03 11:48:55 +00:00
|
|
|
return generate(true)
|
2021-11-08 10:04:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Tombstone returns random object.Tombstone.
|
|
|
|
func Tombstone() *object.Tombstone {
|
|
|
|
x := object.NewTombstone()
|
|
|
|
|
|
|
|
x.SetSplitID(SplitID())
|
|
|
|
x.SetExpirationEpoch(13)
|
2022-04-11 16:25:14 +00:00
|
|
|
x.SetMembers([]oid.ID{oidtest.ID(), oidtest.ID()})
|
2021-11-08 10:04:45 +00:00
|
|
|
|
|
|
|
return x
|
|
|
|
}
|
|
|
|
|
|
|
|
// SplitInfo returns random object.SplitInfo.
|
|
|
|
func SplitInfo() *object.SplitInfo {
|
|
|
|
x := object.NewSplitInfo()
|
|
|
|
|
|
|
|
x.SetSplitID(SplitID())
|
2022-02-01 10:15:12 +00:00
|
|
|
x.SetLink(oidtest.ID())
|
|
|
|
x.SetLastPart(oidtest.ID())
|
2021-11-08 10:04:45 +00:00
|
|
|
|
|
|
|
return x
|
|
|
|
}
|
|
|
|
|
|
|
|
// SearchFilters returns random object.SearchFilters.
|
|
|
|
func SearchFilters() object.SearchFilters {
|
|
|
|
x := object.NewSearchFilters()
|
|
|
|
|
2022-02-01 10:15:12 +00:00
|
|
|
x.AddObjectIDFilter(object.MatchStringEqual, oidtest.ID())
|
2021-11-12 11:19:16 +00:00
|
|
|
x.AddObjectContainerIDFilter(object.MatchStringNotEqual, cidtest.ID())
|
2021-11-08 10:04:45 +00:00
|
|
|
|
|
|
|
return x
|
|
|
|
}
|
2022-03-05 13:54:28 +00:00
|
|
|
|
|
|
|
// Lock returns random object.Lock.
|
|
|
|
func Lock() *object.Lock {
|
|
|
|
var l object.Lock
|
2022-04-11 16:25:14 +00:00
|
|
|
l.WriteMembers([]oid.ID{oidtest.ID(), oidtest.ID()})
|
2022-03-05 13:54:28 +00:00
|
|
|
|
|
|
|
return &l
|
|
|
|
}
|