github.com/argoproj/argo-cd/v2@v2.10.5/test/e2e/notification_test.go (about) 1 package e2e 2 3 import ( 4 "testing" 5 6 "github.com/argoproj/argo-cd/v2/pkg/apiclient/notification" 7 notifFixture "github.com/argoproj/argo-cd/v2/test/e2e/fixture/notification" 8 "github.com/stretchr/testify/assert" 9 "k8s.io/utils/pointer" 10 ) 11 12 func TestNotificationsListServices(t *testing.T) { 13 ctx := notifFixture.Given(t) 14 ctx.When(). 15 SetParamInNotificationConfigMap("service.webhook.test", "url: https://test.example.com"). 16 Then().Services(func(services *notification.ServiceList, err error) { 17 assert.Nil(t, err) 18 assert.Equal(t, []*notification.Service{{Name: pointer.String("test")}}, services.Items) 19 }) 20 } 21 22 func TestNotificationsListTemplates(t *testing.T) { 23 ctx := notifFixture.Given(t) 24 ctx.When(). 25 SetParamInNotificationConfigMap("template.app-created", "email:\n subject: Application {{.app.metadata.name}} has been created.\nmessage: Application {{.app.metadata.name}} has been created.\nteams:\n title: Application {{.app.metadata.name}} has been created.\n"). 26 Then().Templates(func(templates *notification.TemplateList, err error) { 27 assert.Nil(t, err) 28 assert.Equal(t, []*notification.Template{{Name: pointer.String("app-created")}}, templates.Items) 29 }) 30 } 31 32 func TestNotificationsListTriggers(t *testing.T) { 33 ctx := notifFixture.Given(t) 34 ctx.When(). 35 SetParamInNotificationConfigMap("trigger.on-created", "- description: Application is created.\n oncePer: app.metadata.name\n send:\n - app-created\n when: \"true\"\n"). 36 Then().Triggers(func(triggers *notification.TriggerList, err error) { 37 assert.Nil(t, err) 38 assert.Equal(t, []*notification.Trigger{{Name: pointer.String("on-created")}}, triggers.Items) 39 }) 40 }