github.com/argoproj/argo-cd/v2@v2.10.5/test/e2e/fixture/applicationsets/context.go (about) 1 package applicationsets 2 3 import ( 4 "testing" 5 "time" 6 7 "github.com/argoproj/argo-cd/v2/test/e2e/fixture/applicationsets/utils" 8 . "github.com/argoproj/argo-cd/v2/test/e2e/fixture/applicationsets/utils" 9 ) 10 11 // Context implements the "given" part of given/when/then 12 type Context struct { 13 t *testing.T 14 15 // name is the ApplicationSet's name, created by a Create action 16 name string 17 namespace string 18 switchToNamespace utils.ExternalNamespace 19 } 20 21 func Given(t *testing.T) *Context { 22 EnsureCleanState(t) 23 return &Context{t: t} 24 } 25 26 func (c *Context) When() *Actions { 27 // in case any settings have changed, pause for 1s, not great, but fine 28 time.Sleep(1 * time.Second) 29 return &Actions{context: c} 30 } 31 32 func (c *Context) Sleep(seconds time.Duration) *Context { 33 time.Sleep(seconds * time.Second) 34 return c 35 } 36 37 func (c *Context) And(block func()) *Context { 38 block() 39 return c 40 }