github.com/argoproj/argo-cd/v2@v2.10.9/test/e2e/fixture/notification/consequences.go (about)

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