Files
argo-cd/test/e2e/notification_test.go
github-actions[bot] 4d9835927d Bump major version to 3 (#21410)
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: crenshaw-dev <350466+crenshaw-dev@users.noreply.github.com>
2025-01-10 16:14:00 -05:00

53 lines
1.8 KiB
Go

package e2e
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"k8s.io/utils/ptr"
"github.com/argoproj/argo-cd/v3/pkg/apiclient/notification"
notifFixture "github.com/argoproj/argo-cd/v3/test/e2e/fixture/notification"
)
func TestNotificationsListServices(t *testing.T) {
ctx := notifFixture.Given(t)
ctx.When().
SetParamInNotificationConfigMap("service.webhook.test", "url: https://test.example.com").
Then().Services(func(services *notification.ServiceList, err error) {
require.NoError(t, err)
assert.Equal(t, []*notification.Service{{Name: ptr.To("test")}}, services.Items)
})
}
func TestNotificationsListTemplates(t *testing.T) {
ctx := notifFixture.Given(t)
ctx.When().
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").
Then().Templates(func(templates *notification.TemplateList, err error) {
require.NoError(t, err)
assert.Equal(t, []*notification.Template{{Name: ptr.To("app-created")}}, templates.Items)
})
}
func TestNotificationsListTriggers(t *testing.T) {
ctx := notifFixture.Given(t)
ctx.When().
SetParamInNotificationConfigMap("trigger.on-created", "- description: Application is created.\n oncePer: app.metadata.name\n send:\n - app-created\n when: \"true\"\n").
Then().Triggers(func(triggers *notification.TriggerList, err error) {
require.NoError(t, err)
assert.Equal(t, []*notification.Trigger{{Name: ptr.To("on-created")}}, triggers.Items)
})
}
func TestNotificationsHealthcheck(t *testing.T) {
ctx := notifFixture.Given(t)
ctx.When().
Healthcheck().
Then().
Healthy(func(healthy bool) {
assert.True(t, healthy)
})
}