From 2648abb49ed9d50bf0fdc756abad740d38a96041 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Fri, 28 May 2021 13:10:34 +0300 Subject: [PATCH] [#283] pkg/session: Add container context generator Implement `sessiontest.ContainerContext` function for testing. Signed-off-by: Leonard Lyubich --- pkg/session/test/container.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 pkg/session/test/container.go diff --git a/pkg/session/test/container.go b/pkg/session/test/container.go new file mode 100644 index 0000000..070bd1b --- /dev/null +++ b/pkg/session/test/container.go @@ -0,0 +1,26 @@ +package sessiontest + +import ( + "math/rand" + + cidtest "github.com/nspcc-dev/neofs-api-go/pkg/container/id/test" + "github.com/nspcc-dev/neofs-api-go/pkg/session" +) + +// ContainerContext returns session.ContainerContext +// which applies to random operation on a random container. +func ContainerContext() *session.ContainerContext { + c := session.NewContainerContext() + + setters := []func(){ + c.ForPut, + c.ForDelete, + c.ForSetEACL, + } + + setters[rand.Uint32()%uint32(len(setters))]() + + c.ApplyTo(cidtest.Generate()) + + return c +}