github.com/argoproj/argo-cd/v3@v3.2.1/test/e2e/fixture/repos/context.go (about) 1 package repos 2 3 import ( 4 "testing" 5 "time" 6 7 "github.com/argoproj/argo-cd/v3/test/e2e/fixture" 8 ) 9 10 // this implements the "given" part of given/when/then 11 type Context struct { 12 t *testing.T 13 path string 14 name string 15 project string 16 } 17 18 func Given(t *testing.T) *Context { 19 t.Helper() 20 fixture.EnsureCleanState(t) 21 return GivenWithSameState(t) 22 } 23 24 // GivenWithSameState skips cleaning state. Use this when you've already ensured you have a clean 25 // state in your test setup don't want to waste time by doing so again. 26 func GivenWithSameState(t *testing.T) *Context { 27 t.Helper() 28 return &Context{t: t, name: fixture.Name(), project: "default"} 29 } 30 31 func (c *Context) GetName() string { 32 return c.name 33 } 34 35 func (c *Context) Name(name string) *Context { 36 c.name = name 37 return c 38 } 39 40 func (c *Context) And(block func()) *Context { 41 block() 42 return c 43 } 44 45 func (c *Context) When() *Actions { 46 time.Sleep(fixture.WhenThenSleepInterval) 47 return &Actions{context: c} 48 } 49 50 func (c *Context) Project(project string) *Context { 51 c.project = project 52 return c 53 }