[#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:
parent
1d8207ae19
commit
2648abb49e
1 changed files with 26 additions and 0 deletions
26
pkg/session/test/container.go
Normal file
26
pkg/session/test/container.go
Normal 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
|
||||||
|
}
|
Loading…
Reference in a new issue