Skip to content

Commit

Permalink
Fix: integration test 025 is not isolated (#735)
Browse files Browse the repository at this point in the history
* make the test rely solely on its own data

* make the notifications data use the resource name, output from all notifications for testing its functionality

---------

Co-authored-by: Tomer Heber <[email protected]>
  • Loading branch information
sagilaufer1992 and TomerHeber committed Oct 25, 2023
1 parent bb5f991 commit 6591632
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
4 changes: 3 additions & 1 deletion tests/integration/025_notifications/expected_outputs.json
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
{}
{
"notification_1_from_all_notifications": "integration-test-025-notification-1-"
}
34 changes: 28 additions & 6 deletions tests/integration/025_notifications/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
, ""
)
}

0 comments on commit 6591632

Please sign in to comment.