diff --git a/tests/integration/025_notifications/expected_outputs.json b/tests/integration/025_notifications/expected_outputs.json index 0967ef42..eaaaa465 100644 --- a/tests/integration/025_notifications/expected_outputs.json +++ b/tests/integration/025_notifications/expected_outputs.json @@ -1 +1,3 @@ -{} +{ + "notification_1_from_all_notifications": "integration-test-025-notification-1-" +} diff --git a/tests/integration/025_notifications/main.tf b/tests/integration/025_notifications/main.tf index 5c8186b1..172cb852 100644 --- a/tests/integration/025_notifications/main.tf +++ b/tests/integration/025_notifications/main.tf @@ -6,21 +6,43 @@ resource "random_string" "random" { min_lower = 20 } +locals { + notification_name_prefix = "integration-test-025-notification" +} + resource "env0_notification" "test_notification_1" { - name = "notification123-${random_string.random.result}-1" + name = "${local.notification_name_prefix}-1-${random_string.random.result}" type = "Slack" value = "https://someurl1.com" } resource "env0_notification" "test_notification_2" { - name = "notification123-${random_string.random.result}-2" + name = "${local.notification_name_prefix}-2-${random_string.random.result}" type = "Teams" value = "https://someurl2.com" } -data "env0_notifications" "all_notifications" {} +data "env0_notifications" "all_notifications" { + depends_on = [env0_notification.test_notification_1, env0_notification.test_notification_2] +} + +data "env0_notification" "test_notification_1" { + depends_on = [env0_notification.test_notification_1] + name = "${local.notification_name_prefix}-1-${random_string.random.result}" +} + +data "env0_notification" "test_notification_2" { + depends_on = [env0_notification.test_notification_2] + name = "${local.notification_name_prefix}-2-${random_string.random.result}" +} -data "env0_notification" "notification" { - for_each = toset(data.env0_notifications.all_notifications.names) - name = each.value +output "notification_1_from_all_notifications" { + value = replace( + data.env0_notifications.all_notifications.names[ + index(data.env0_notifications.all_notifications.names, + env0_notification.test_notification_1.name) + ] + , random_string.random.result + , "" + ) }