github.com/argoproj/argo-cd/v3@v3.2.1/test/e2e/notification_test.go (about) 1 package e2e 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/assert" 7 "github.com/stretchr/testify/require" 8 "k8s.io/utils/ptr" 9 10 "github.com/argoproj/argo-cd/v3/pkg/apiclient/notification" 11 notifFixture "github.com/argoproj/argo-cd/v3/test/e2e/fixture/notification" 12 ) 13 14 func TestNotificationsListServices(t *testing.T) { 15 ctx := notifFixture.Given(t) 16 ctx.When(). 17 SetParamInNotificationConfigMap("service.webhook.test", "url: https://test.example.com"). 18 Then().Services(func(services *notification.ServiceList, err error) { 19 require.NoError(t, err) 20 assert.Equal(t, []*notification.Service{{Name: ptr.To("test")}}, services.Items) 21 }) 22 } 23 24 func TestNotificationsListTemplates(t *testing.T) { 25 ctx := notifFixture.Given(t) 26 ctx.When(). 27 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"). 28 Then().Templates(func(templates *notification.TemplateList, err error) { 29 require.NoError(t, err) 30 assert.Equal(t, []*notification.Template{{Name: ptr.To("app-created")}}, templates.Items) 31 }) 32 } 33 34 func TestNotificationsListTriggers(t *testing.T) { 35 ctx := notifFixture.Given(t) 36 ctx.When(). 37 SetParamInNotificationConfigMap("trigger.on-created", "- description: Application is created.\n oncePer: app.metadata.name\n send:\n - app-created\n when: \"true\"\n"). 38 Then().Triggers(func(triggers *notification.TriggerList, err error) { 39 require.NoError(t, err) 40 assert.Equal(t, []*notification.Trigger{{Name: ptr.To("on-created")}}, triggers.Items) 41 }) 42 } 43 44 func TestNotificationsHealthcheck(t *testing.T) { 45 ctx := notifFixture.Given(t) 46 ctx.When(). 47 Healthcheck(). 48 Then(). 49 Healthy(func(healthy bool) { 50 assert.True(t, healthy) 51 }) 52 }