From 061c4422f32b65f10247328173fa227e7c78e691 Mon Sep 17 00:00:00 2001 From: Tomer Heber Date: Tue, 21 May 2024 09:20:16 -0500 Subject: [PATCH] Feat: fix the integration test (#854) * Feat: fix the integration test * modified test and added webhook support * updated description --- client/notification.go | 7 ++++--- env0/resource_notification.go | 4 ++-- env0/resource_notification_test.go | 2 +- tests/integration/025_notifications/main.tf | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/client/notification.go b/client/notification.go index 8f9a2679..dd0cae29 100644 --- a/client/notification.go +++ b/client/notification.go @@ -3,9 +3,10 @@ package client type NotificationType string const ( - NotificationTypeSlack NotificationType = "Slack" - NotificationTypeTeams NotificationType = "Teams" - NotificationTypeEmail NotificationType = "Email" + NotificationTypeSlack NotificationType = "Slack" + NotificationTypeTeams NotificationType = "Teams" + NotificationTypeEmail NotificationType = "Email" + NotificationTypeWebhook NotificationType = "Webhook" ) type Notification struct { diff --git a/env0/resource_notification.go b/env0/resource_notification.go index b443a928..9b946e1a 100644 --- a/env0/resource_notification.go +++ b/env0/resource_notification.go @@ -30,11 +30,11 @@ func resourceNotification() *schema.Resource { }, "type": { Type: schema.TypeString, - Description: "'Slack', 'Teams' or 'Email'", + Description: "'Slack', 'Teams', 'Email' or 'Webhook'", Required: true, ValidateDiagFunc: func(i interface{}, path cty.Path) diag.Diagnostics { notificationType := client.NotificationType(i.(string)) - if notificationType != client.NotificationTypeSlack && notificationType != client.NotificationTypeTeams && notificationType != client.NotificationTypeEmail { + if notificationType != client.NotificationTypeSlack && notificationType != client.NotificationTypeTeams && notificationType != client.NotificationTypeEmail && notificationType != client.NotificationTypeWebhook { return diag.Errorf("Invalid notification type") } return nil diff --git a/env0/resource_notification_test.go b/env0/resource_notification_test.go index e5c9ea48..f03bc3e5 100644 --- a/env0/resource_notification_test.go +++ b/env0/resource_notification_test.go @@ -43,7 +43,7 @@ func TestUnitNotificationResource(t *testing.T) { updatedNotification := client.Notification{ Id: notification.Id, - Type: client.NotificationTypeTeams, + Type: client.NotificationTypeWebhook, Name: "name0-updated", Value: "https://some.updated.url.1.com", OrganizationId: notification.OrganizationId, diff --git a/tests/integration/025_notifications/main.tf b/tests/integration/025_notifications/main.tf index dce548e3..93abafad 100644 --- a/tests/integration/025_notifications/main.tf +++ b/tests/integration/025_notifications/main.tf @@ -12,7 +12,7 @@ locals { resource "env0_notification" "test_notification_1" { name = "${local.notification_name_prefix}-1-${random_string.random.result}" - type = "Slack" + type = "Webhook" value = "https://someurl1.com" webhook_secret = "my_little_secret" }