[#283] pkg/session: Add container context generator

Implement `sessiontest.ContainerContext` function for testing.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-05-28 13:10:34 +03:00 committed by Leonard Lyubich
parent 1d8207ae19
commit 2648abb49e

View file

@ -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
}