github.com/argoproj/argo-cd/v3@v3.2.1/test/e2e/fixture/cluster/context.go (about) 1 package cluster 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 name string 14 project string 15 server string 16 upsert bool 17 namespaces []string 18 bearerToken string 19 } 20 21 func Given(t *testing.T) *Context { 22 t.Helper() 23 fixture.EnsureCleanState(t) 24 return GivenWithSameState(t) 25 } 26 27 func GivenWithSameState(t *testing.T) *Context { 28 t.Helper() 29 return &Context{t: t, name: fixture.Name(), project: "default"} 30 } 31 32 func (c *Context) GetName() string { 33 return c.name 34 } 35 36 func (c *Context) Name(name string) *Context { 37 c.name = name 38 return c 39 } 40 41 func (c *Context) Server(server string) *Context { 42 c.server = server 43 return c 44 } 45 46 func (c *Context) Namespaces(namespaces []string) *Context { 47 c.namespaces = namespaces 48 return c 49 } 50 51 func (c *Context) And(block func()) *Context { 52 block() 53 return c 54 } 55 56 func (c *Context) When() *Actions { 57 time.Sleep(fixture.WhenThenSleepInterval) 58 return &Actions{context: c} 59 } 60 61 func (c *Context) Project(project string) *Context { 62 c.project = project 63 return c 64 } 65 66 func (c *Context) BearerToken(bearerToken string) *Context { 67 c.bearerToken = bearerToken 68 return c 69 } 70 71 func (c *Context) Upsert(upsert bool) *Context { 72 c.upsert = upsert 73 return c 74 }