2021-11-08 12:25:13 +00:00
|
|
|
package containertest
|
|
|
|
|
|
|
|
import (
|
2022-06-21 09:42:18 +00:00
|
|
|
"math/rand"
|
2023-04-25 09:11:42 +00:00
|
|
|
"testing"
|
2022-06-21 09:42:18 +00:00
|
|
|
|
2021-11-08 12:25:13 +00:00
|
|
|
"github.com/nspcc-dev/neofs-sdk-go/container"
|
2022-06-20 15:28:27 +00:00
|
|
|
"github.com/nspcc-dev/neofs-sdk-go/container/acl"
|
2021-11-08 12:25:13 +00:00
|
|
|
cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test"
|
|
|
|
netmaptest "github.com/nspcc-dev/neofs-sdk-go/netmap/test"
|
2022-04-11 06:30:22 +00:00
|
|
|
usertest "github.com/nspcc-dev/neofs-sdk-go/user/test"
|
2021-11-08 12:25:13 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Container returns random container.Container.
|
2023-04-25 09:11:42 +00:00
|
|
|
func Container(t *testing.T) (x container.Container) {
|
|
|
|
owner := usertest.ID(t)
|
2021-11-08 12:25:13 +00:00
|
|
|
|
2022-06-25 09:54:42 +00:00
|
|
|
x.Init()
|
|
|
|
x.SetAttribute("some attribute", "value")
|
|
|
|
x.SetOwner(*owner)
|
2022-06-20 15:28:27 +00:00
|
|
|
x.SetBasicACL(BasicACL())
|
2022-06-25 09:54:42 +00:00
|
|
|
x.SetPlacementPolicy(netmaptest.PlacementPolicy())
|
2021-11-08 12:25:13 +00:00
|
|
|
|
|
|
|
return x
|
|
|
|
}
|
|
|
|
|
2022-06-25 09:54:42 +00:00
|
|
|
// SizeEstimation returns random container.SizeEstimation.
|
|
|
|
func SizeEstimation() (x container.SizeEstimation) {
|
|
|
|
x.SetContainer(cidtest.ID())
|
|
|
|
x.SetEpoch(rand.Uint64())
|
|
|
|
x.SetValue(rand.Uint64())
|
2021-11-08 12:25:13 +00:00
|
|
|
|
|
|
|
return x
|
|
|
|
}
|
2022-06-20 15:28:27 +00:00
|
|
|
|
|
|
|
// BasicACL returns random acl.Basic.
|
|
|
|
func BasicACL() (x acl.Basic) {
|
2022-06-21 09:42:18 +00:00
|
|
|
x.FromBits(rand.Uint32())
|
2022-06-20 15:28:27 +00:00
|
|
|
return
|
|
|
|
}
|