frostfs-api-go/pkg/session/test/container.go
Leonard Lyubich 2648abb49e [#283] pkg/session: Add container context generator
Implement `sessiontest.ContainerContext` function for testing.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-05-28 16:32:02 +03:00

26 lines
526 B
Go

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
}