github.com/argoproj/argo-cd/v3@v3.2.1/test/e2e/fixture/notification/consequences.go (about) 1 package notification 2 3 import ( 4 "context" 5 "time" 6 7 "github.com/argoproj/argo-cd/v3/pkg/apiclient/notification" 8 "github.com/argoproj/argo-cd/v3/test/e2e/fixture" 9 ) 10 11 // this implements the "then" part of given/when/then 12 type Consequences struct { 13 context *Context 14 actions *Actions 15 } 16 17 func (c *Consequences) Services(block func(services *notification.ServiceList, err error)) *Consequences { 18 c.context.t.Helper() 19 block(c.listServices()) 20 return c 21 } 22 23 func (c *Consequences) Healthy(block func(healthy bool)) *Consequences { 24 c.context.t.Helper() 25 block(c.actions.healthy) 26 return c 27 } 28 29 func (c *Consequences) Triggers(block func(services *notification.TriggerList, err error)) *Consequences { 30 c.context.t.Helper() 31 block(c.listTriggers()) 32 return c 33 } 34 35 func (c *Consequences) Templates(block func(services *notification.TemplateList, err error)) *Consequences { 36 c.context.t.Helper() 37 block(c.listTemplates()) 38 return c 39 } 40 41 func (c *Consequences) listServices() (*notification.ServiceList, error) { 42 _, notifClient, _ := fixture.ArgoCDClientset.NewNotificationClient() 43 return notifClient.ListServices(context.Background(), ¬ification.ServicesListRequest{}) 44 } 45 46 func (c *Consequences) listTriggers() (*notification.TriggerList, error) { 47 _, notifClient, _ := fixture.ArgoCDClientset.NewNotificationClient() 48 return notifClient.ListTriggers(context.Background(), ¬ification.TriggersListRequest{}) 49 } 50 51 func (c *Consequences) listTemplates() (*notification.TemplateList, error) { 52 _, notifClient, _ := fixture.ArgoCDClientset.NewNotificationClient() 53 return notifClient.ListTemplates(context.Background(), ¬ification.TemplatesListRequest{}) 54 } 55 56 func (c *Consequences) When() *Actions { 57 time.Sleep(fixture.WhenThenSleepInterval) 58 return c.actions 59 } 60 61 func (c *Consequences) Given() *Context { 62 return c.context 63 }