mirror of
https://github.com/hanzoai/deploy.git
synced 2026-10-07 08:44:50 +00:00
Signed-off-by: Alexandre Gaudreault <[email protected]> Signed-off-by: Kanika Rana <[email protected]> Signed-off-by: Kanika Rana <[email protected]> Signed-off-by: Oliver Gondža <[email protected]> Co-authored-by: Alexandre Gaudreault <[email protected]> Co-authored-by: Oliver Gondža <[email protected]>
64 lines
1.8 KiB
Go
64 lines
1.8 KiB
Go
package notification
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/argoproj/argo-cd/v3/pkg/apiclient/notification"
|
|
"github.com/argoproj/argo-cd/v3/test/e2e/fixture"
|
|
)
|
|
|
|
// this implements the "then" part of given/when/then
|
|
type Consequences struct {
|
|
context *Context
|
|
actions *Actions
|
|
}
|
|
|
|
func (c *Consequences) Services(block func(services *notification.ServiceList, err error)) *Consequences {
|
|
c.context.T().Helper()
|
|
block(c.listServices())
|
|
return c
|
|
}
|
|
|
|
func (c *Consequences) Healthy(block func(healthy bool)) *Consequences {
|
|
c.context.T().Helper()
|
|
block(c.actions.healthy)
|
|
return c
|
|
}
|
|
|
|
func (c *Consequences) Triggers(block func(services *notification.TriggerList, err error)) *Consequences {
|
|
c.context.T().Helper()
|
|
block(c.listTriggers())
|
|
return c
|
|
}
|
|
|
|
func (c *Consequences) Templates(block func(services *notification.TemplateList, err error)) *Consequences {
|
|
c.context.T().Helper()
|
|
block(c.listTemplates())
|
|
return c
|
|
}
|
|
|
|
func (c *Consequences) listServices() (*notification.ServiceList, error) {
|
|
_, notifClient, _ := fixture.ArgoCDClientset.NewNotificationClient()
|
|
return notifClient.ListServices(context.Background(), ¬ification.ServicesListRequest{})
|
|
}
|
|
|
|
func (c *Consequences) listTriggers() (*notification.TriggerList, error) {
|
|
_, notifClient, _ := fixture.ArgoCDClientset.NewNotificationClient()
|
|
return notifClient.ListTriggers(context.Background(), ¬ification.TriggersListRequest{})
|
|
}
|
|
|
|
func (c *Consequences) listTemplates() (*notification.TemplateList, error) {
|
|
_, notifClient, _ := fixture.ArgoCDClientset.NewNotificationClient()
|
|
return notifClient.ListTemplates(context.Background(), ¬ification.TemplatesListRequest{})
|
|
}
|
|
|
|
func (c *Consequences) When() *Actions {
|
|
time.Sleep(fixture.WhenThenSleepInterval)
|
|
return c.actions
|
|
}
|
|
|
|
func (c *Consequences) Given() *Context {
|
|
return c.context
|
|
}
|