From 090101083bf47784d36f5afd3d460bce422cdf59 Mon Sep 17 00:00:00 2001 From: Benjamin Smith Date: Tue, 23 Jul 2024 10:35:10 -0700 Subject: [PATCH] [Tests] Update GHA to run all tests (#76) * update makefile in test * run all tests * update tests * cleanup test conflicts with eachother (same resources) * update deduplication and delay action vars * terraform fmt * terraform fmt * suppress toggled off for dedup * fix some tests * fix some tests * skip some tests and update module.this.id * fix value examples routing rule * time_restriction is an array * time_restriction is an array * update teams to avoid conflicts * update restrictions * update restrictions * fix * turn of notiication policy, fix value for routing rule, add user for config * all teams are dynamic * update scheudle config * skip config --- examples/advanced_features/fixtures.tfvars | 1 - examples/alert_policy/fixtures.tfvars | 1 - examples/config/fixtures.tfvars | 1 - examples/config/resources/escalations.yaml | 3 +- .../resources/notification_policies.yaml | 14 +++++- .../config/resources/schedule_rotations.yaml | 6 +-- examples/config/resources/schedules.yaml | 4 +- examples/config/resources/users.yaml | 6 +++ examples/escalation/fixtures.tfvars | 1 - examples/escalation/main.tf | 6 +-- examples/integration_action/fixtures.tfvars | 1 - .../fixtures.de_duplication_action.tfvars | 12 +++++ .../fixtures.delay_action.tfvars | 12 +++++ examples/notification_policy/fixtures.tfvars | 4 -- examples/notification_policy/main.tf | 32 ++++++------- examples/notification_policy/variables.tf | 31 ++++++++++++ examples/schedule/fixtures.tfvars | 1 - examples/schedule/main.tf | 2 +- examples/team/fixtures.tfvars | 1 - examples/team_routing_rule/fixtures.tfvars | 1 - examples/team_routing_rule/main.tf | 30 +++++++----- examples/user/fixtures.tfvars | 1 - examples/user/main.tf | 2 +- examples/user/variables.tf | 6 +++ modules/config/escalations.tf | 2 +- modules/notification_policy/main.tf | 6 +-- test/Makefile | 30 +++++++++++- test/src/Makefile | 2 +- test/src/examples_alert_policy_test.go | 4 ++ test/src/examples_api_integration_test.go | 3 +- test/src/examples_config_test.go | 3 ++ test/src/examples_escalation_test.go | 4 +- test/src/examples_notification_policy_test.go | 47 ++++++++++++++++++- test/src/examples_team_routing_rule_test.go | 4 +- test/src/examples_team_test.go | 5 +- test/src/examples_user_test.go | 3 +- 36 files changed, 221 insertions(+), 71 deletions(-) create mode 100644 examples/notification_policy/fixtures.de_duplication_action.tfvars create mode 100644 examples/notification_policy/fixtures.delay_action.tfvars delete mode 100644 examples/notification_policy/fixtures.tfvars diff --git a/examples/advanced_features/fixtures.tfvars b/examples/advanced_features/fixtures.tfvars index 2660254..fd0cf27 100644 --- a/examples/advanced_features/fixtures.tfvars +++ b/examples/advanced_features/fixtures.tfvars @@ -1,4 +1,3 @@ -enabled = true namespace = "eg" name = "incident-management-workflow" stage = "test" diff --git a/examples/alert_policy/fixtures.tfvars b/examples/alert_policy/fixtures.tfvars index 21855f7..57d016a 100644 --- a/examples/alert_policy/fixtures.tfvars +++ b/examples/alert_policy/fixtures.tfvars @@ -1,4 +1,3 @@ -enabled = true namespace = "eg" name = "alert-policy" stage = "test" diff --git a/examples/config/fixtures.tfvars b/examples/config/fixtures.tfvars index 4ad9361..e69de29 100644 --- a/examples/config/fixtures.tfvars +++ b/examples/config/fixtures.tfvars @@ -1 +0,0 @@ -enabled = true diff --git a/examples/config/resources/escalations.yaml b/examples/config/resources/escalations.yaml index dcd71e4..d3f98e1 100644 --- a/examples/config/resources/escalations.yaml +++ b/examples/config/resources/escalations.yaml @@ -2,7 +2,8 @@ escalations: - name: acme.dev.some-service-escalation description: "repo: https://github.com/acme/some-service;owner:David Lightman @David Lightman" owner_team_name: acme.dev - rule: + # please note - config uses `rules` but escalation modules uses `rule` + rules: condition: if-not-acked notify_type: default delay: 0 diff --git a/examples/config/resources/notification_policies.yaml b/examples/config/resources/notification_policies.yaml index a351b09..241fa5a 100644 --- a/examples/config/resources/notification_policies.yaml +++ b/examples/config/resources/notification_policies.yaml @@ -2,7 +2,8 @@ notification_policies: - name: auto-close-based-on-priority team_name: acme.dev auto_close_action: - time_amount: 60 + duration: + time_amount: 60 filter: type: match-all-conditions conditions: @@ -16,6 +17,17 @@ notification_policies: time_unit: minutes time_amount: 5 +- name: delay-action-test + team_name: acme.dev + auto_close_action: + duration: + time_amount: 60 + filter: + type: match-all-conditions + conditions: + - field: priority + operation: less-than + expected_value: P3 delay_action: delay_option: for-duration duration: diff --git a/examples/config/resources/schedule_rotations.yaml b/examples/config/resources/schedule_rotations.yaml index f950fb6..720ad2b 100644 --- a/examples/config/resources/schedule_rotations.yaml +++ b/examples/config/resources/schedule_rotations.yaml @@ -1,6 +1,6 @@ schedule_rotations: - - name: acme.default.rotation - schedule_name: acme.default + - name: acme.default.rotation + schedule_name: acme-default start_date: "1970-01-01T00:00:00Z" type: weekly length: 1 @@ -15,4 +15,4 @@ schedule_rotations: - start_hour: 8 start_min: 0 end_hour: 20 - end_min: 0 \ No newline at end of file + end_min: 0 diff --git a/examples/config/resources/schedules.yaml b/examples/config/resources/schedules.yaml index 32b1c77..bae64f0 100644 --- a/examples/config/resources/schedules.yaml +++ b/examples/config/resources/schedules.yaml @@ -1,6 +1,6 @@ schedules: - - name: acme.default + - name: acme-default description: "Acme Infrastructure Team" timezone: "America/Los_Angeles" owner_team_name: acme - enabled: true \ No newline at end of file + enabled: true diff --git a/examples/config/resources/users.yaml b/examples/config/resources/users.yaml index 2ab33d1..a55e929 100644 --- a/examples/config/resources/users.yaml +++ b/examples/config/resources/users.yaml @@ -4,3 +4,9 @@ users: role: User locale: "en_US" timezone: "America/New_York" + + - username: opsgenie-test-2@cloudposse.com + full_name: Opsgenie Test User 2 + role: User + locale: "en_US" + timezone: "America/New_York" diff --git a/examples/escalation/fixtures.tfvars b/examples/escalation/fixtures.tfvars index 544a4a0..ec8aad4 100644 --- a/examples/escalation/fixtures.tfvars +++ b/examples/escalation/fixtures.tfvars @@ -1,4 +1,3 @@ -enabled = true namespace = "eg" name = "escalation" stage = "test" diff --git a/examples/escalation/main.tf b/examples/escalation/main.tf index 24f8998..ef548c0 100644 --- a/examples/escalation/main.tf +++ b/examples/escalation/main.tf @@ -6,7 +6,7 @@ module "owner_team" { source = "../../modules/team" team = { - name = "owner-team" + name = format("%s-%s", module.this.id, "owner-team") description = "owner-team-description" } @@ -17,7 +17,7 @@ module "escalation_team" { source = "../../modules/team" team = { - name = "escalation-team" + name = format("%s-%s", module.this.id, "escalation-team") description = "owner-team-description" } @@ -39,5 +39,5 @@ module "escalation" { } } - context = module.this.contexts + context = module.this.context } diff --git a/examples/integration_action/fixtures.tfvars b/examples/integration_action/fixtures.tfvars index 83719e9..c773816 100644 --- a/examples/integration_action/fixtures.tfvars +++ b/examples/integration_action/fixtures.tfvars @@ -1,4 +1,3 @@ -enabled = true namespace = "eg" name = "integration" stage = "test" diff --git a/examples/notification_policy/fixtures.de_duplication_action.tfvars b/examples/notification_policy/fixtures.de_duplication_action.tfvars new file mode 100644 index 0000000..68db53d --- /dev/null +++ b/examples/notification_policy/fixtures.de_duplication_action.tfvars @@ -0,0 +1,12 @@ +namespace = "eg" +name = "notification-policy" +stage = "test" + +de_duplication_action = { + de_duplication_action_type = "frequency-based" + count = 2 + duration = { + time_unit = "minutes" + time_amount = 5 + } +} diff --git a/examples/notification_policy/fixtures.delay_action.tfvars b/examples/notification_policy/fixtures.delay_action.tfvars new file mode 100644 index 0000000..8f2d4b0 --- /dev/null +++ b/examples/notification_policy/fixtures.delay_action.tfvars @@ -0,0 +1,12 @@ +namespace = "eg" +name = "notification-policy" +stage = "test" + +delay_action = { + delay_option = "for-duration" + duration = { + time_unit = "minutes" + time_amount = 10 + } +} + diff --git a/examples/notification_policy/fixtures.tfvars b/examples/notification_policy/fixtures.tfvars deleted file mode 100644 index 3d955ed..0000000 --- a/examples/notification_policy/fixtures.tfvars +++ /dev/null @@ -1,4 +0,0 @@ -enabled = true -namespace = "eg" -name = "notification-policy" -stage = "test" diff --git a/examples/notification_policy/main.tf b/examples/notification_policy/main.tf index 6be0088..725c5e5 100644 --- a/examples/notification_policy/main.tf +++ b/examples/notification_policy/main.tf @@ -6,7 +6,7 @@ module "team" { source = "../../modules/team" team = { - name = "owner-team" + name = module.this.id description = "owner-team-description" } @@ -22,34 +22,34 @@ module "notification_policy" { filter = { type = "match-all-conditions" - conditions = [{ - field = "tags" - operation = "contains" - expected_value = "recommendation:auto-close" - }] + conditions = [ + { + field = "tags" + operation = "contains" + expected_value = "recommendation:auto-close" + } + ] } - de_duplication_action = { - de_duplication_action_type = "frequency-based" - count = 2 + de_duplication_action = var.de_duplication_action + delay_action = var.delay_action + + auto_close_action = { duration = { time_unit = "minutes" time_amount = 5 } } - delay_action = { - delay_option = "for-duration" + auto_restart_action = { duration = { time_unit = "minutes" - time_amount = 10 + time_amount = 5 } + max_repeat_count = 3 } - auto_close_action = { - time_unit = "minutes" - time_amount = 5 - } + suppress = var.suppress } context = module.this.context diff --git a/examples/notification_policy/variables.tf b/examples/notification_policy/variables.tf index 841a369..e465aa7 100644 --- a/examples/notification_policy/variables.tf +++ b/examples/notification_policy/variables.tf @@ -3,3 +3,34 @@ variable "opsgenie_provider_api_key" { description = "The API Key for the Opsgenie Integration. If omitted, the OPSGENIE_API_KEY environment variable is used" default = null } + +variable "de_duplication_action" { + type = object({ + de_duplication_action_type = string + count = number + duration = object({ + time_unit = string + time_amount = number + }) + }) + description = "The de-duplication action for the notification policy" + default = null +} + +variable "delay_action" { + type = object({ + delay_option = string + duration = object({ + time_unit = string + time_amount = number + }) + }) + description = "The delay action for the notification policy" + default = null +} + +variable "suppress" { + type = bool + description = "The suppress flag for the notification policy" + default = null +} diff --git a/examples/schedule/fixtures.tfvars b/examples/schedule/fixtures.tfvars index de4d441..7679e72 100644 --- a/examples/schedule/fixtures.tfvars +++ b/examples/schedule/fixtures.tfvars @@ -1,4 +1,3 @@ -enabled = true namespace = "eg" name = "schedule" stage = "test" diff --git a/examples/schedule/main.tf b/examples/schedule/main.tf index 7696a68..04f32b1 100644 --- a/examples/schedule/main.tf +++ b/examples/schedule/main.tf @@ -6,7 +6,7 @@ module "owner_team" { source = "../../modules/team" team = { - name = "owner-team" + name = format("%s-%s", module.this.id, "owner-team") description = "owner-team-description" } diff --git a/examples/team/fixtures.tfvars b/examples/team/fixtures.tfvars index 117dd49..9f0cdc3 100644 --- a/examples/team/fixtures.tfvars +++ b/examples/team/fixtures.tfvars @@ -1,4 +1,3 @@ -enabled = true namespace = "eg" name = "team" stage = "test" diff --git a/examples/team_routing_rule/fixtures.tfvars b/examples/team_routing_rule/fixtures.tfvars index ce6a918..6a2a15a 100644 --- a/examples/team_routing_rule/fixtures.tfvars +++ b/examples/team_routing_rule/fixtures.tfvars @@ -1,4 +1,3 @@ -enabled = true namespace = "eg" name = "team-routing-rule" stage = "test" diff --git a/examples/team_routing_rule/main.tf b/examples/team_routing_rule/main.tf index fe5b39c..c03a42f 100644 --- a/examples/team_routing_rule/main.tf +++ b/examples/team_routing_rule/main.tf @@ -6,8 +6,8 @@ module "escalation_team" { source = "../../modules/team" team = { - name = "escalation-team" - description = "owner-team-description" + name = module.this.id + description = "escalation-team-description" } context = module.this.context @@ -21,10 +21,12 @@ module "escalation" { owner_team_id = module.owner_team.team_id rule = { - recipients = [{ - type = "team" - id = module.escalation_team.team_id - }] + recipients = [ + { + type = "team" + id = module.escalation_team.team_id + } + ] } } @@ -35,7 +37,7 @@ module "owner_team" { source = "../../modules/team" team = { - name = "owner-team" + name = format("%s-%s", module.this.id, "owner-team") description = "owner-team-description" } @@ -58,12 +60,14 @@ module "team_routing_rule" { time_restriction = { type = "time-of-day" - restriction = { - end_hour = 17 - end_min = 0 - start_hour = 9 - start_min = 0 - } + restrictions = [ + { + end_hour = 17 + end_min = 0 + start_hour = 9 + start_min = 0 + } + ] } } diff --git a/examples/user/fixtures.tfvars b/examples/user/fixtures.tfvars index 1567b33..5a09721 100644 --- a/examples/user/fixtures.tfvars +++ b/examples/user/fixtures.tfvars @@ -1,4 +1,3 @@ -enabled = true namespace = "eg" stage = "test" name = "user" diff --git a/examples/user/main.tf b/examples/user/main.tf index bf6f11e..6566eb3 100644 --- a/examples/user/main.tf +++ b/examples/user/main.tf @@ -6,7 +6,7 @@ module "user" { source = "../../modules/user" user = { - username = "opsgenie-test@cloudposse.com" + username = format("opsgenie-test+%s@cloudposse.com", var.random_string) full_name = "Opsgenie Test User" role = "User" locale = "en_US" diff --git a/examples/user/variables.tf b/examples/user/variables.tf index 841a369..66f223c 100644 --- a/examples/user/variables.tf +++ b/examples/user/variables.tf @@ -3,3 +3,9 @@ variable "opsgenie_provider_api_key" { description = "The API Key for the Opsgenie Integration. If omitted, the OPSGENIE_API_KEY environment variable is used" default = null } + +variable "random_string" { + type = string + description = "A random string to append to the resource names" + default = null +} diff --git a/modules/config/escalations.tf b/modules/config/escalations.tf index 8c81d9c..378cae7 100644 --- a/modules/config/escalations.tf +++ b/modules/config/escalations.tf @@ -8,7 +8,7 @@ resource "opsgenie_escalation" "this" { owner_team_id = try(opsgenie_team.this[each.value.owner_team_name].id, null) dynamic "rules" { - for_each = try(each.value.rules, []) + for_each = try([each.value.rules], []) content { condition = try(rules.value.condition, "if-not-acked") diff --git a/modules/notification_policy/main.tf b/modules/notification_policy/main.tf index 7b61a3e..3394579 100644 --- a/modules/notification_policy/main.tf +++ b/modules/notification_policy/main.tf @@ -58,7 +58,7 @@ resource "opsgenie_notification_policy" "this" { } dynamic "auto_close_action" { - for_each = try(each.value.auto_close_action, null) != null ? [each.value.auto_close_action] : [] + for_each = try(var.notification_policy.auto_close_action, null) != null ? [var.notification_policy.auto_close_action] : [] content { duration { @@ -70,7 +70,7 @@ resource "opsgenie_notification_policy" "this" { } dynamic "auto_restart_action" { - for_each = try(each.value.auto_restart_action, null) != null ? [each.value.auto_restart_action] : [] + for_each = try(var.notification_policy.auto_restart_action, null) != null ? [var.notification_policy.auto_restart_action] : [] content { duration { @@ -120,5 +120,5 @@ resource "opsgenie_notification_policy" "this" { } } - suppress = try(each.value.suppress, null) + suppress = try(var.notification_policy.suppress, null) } diff --git a/test/Makefile b/test/Makefile index 17b2fe7..7e7c278 100644 --- a/test/Makefile +++ b/test/Makefile @@ -30,14 +30,40 @@ clean: [ "$(TEST_HARNESS_PATH)" == "/" ] || rm -rf $(TEST_HARNESS_PATH) ## Run all tests -all: module examples/complete +all: module pre-test examples/complete examples/advanced_features examples/alert_policy examples/api_integration examples/complete examples/config examples/escalation examples/integration_action examples/notification_policy examples/schedule examples/team examples/team_routing_rule examples/user ## Run basic sanity checks against the module itself module: export TESTS ?= installed lint get-modules module-pinning get-plugins provider-pinning validate terraform-docs input-descriptions output-descriptions module: deps $(call RUN_TESTS, ../) +pre-test: + export TESTS ?= installed lint get-modules get-plugins validate + ## Run tests against example -examples/complete: export TESTS ?= installed lint get-modules get-plugins validate examples/complete: deps $(call RUN_TESTS, ../$@) +examples/advanced_features: deps + $(call RUN_TESTS, ../$@) +examples/alert_policy: deps + $(call RUN_TESTS, ../$@) +examples/api_integration: deps + $(call RUN_TESTS, ../$@) +examples/complete: deps + $(call RUN_TESTS, ../$@) +examples/config: deps + $(call RUN_TESTS, ../$@) +examples/escalation: deps + $(call RUN_TESTS, ../$@) +examples/integration_action: deps + $(call RUN_TESTS, ../$@) +examples/notification_policy: deps + $(call RUN_TESTS, ../$@) +examples/schedule: deps + $(call RUN_TESTS, ../$@) +examples/team: deps + $(call RUN_TESTS, ../$@) +examples/team_routing_rule: deps + $(call RUN_TESTS, ../$@) +examples/user: deps + $(call RUN_TESTS, ../$@) diff --git a/test/src/Makefile b/test/src/Makefile index 2707cd2..06b00ee 100644 --- a/test/src/Makefile +++ b/test/src/Makefile @@ -16,7 +16,7 @@ init: ## Run tests test: init go mod download - go test -v -timeout 60m -run TestExamplesComplete + go test -v -timeout 60m -parallel 8 ## Run tests in docker container docker/test: diff --git a/test/src/examples_alert_policy_test.go b/test/src/examples_alert_policy_test.go index 9d8b727..b449f8d 100644 --- a/test/src/examples_alert_policy_test.go +++ b/test/src/examples_alert_policy_test.go @@ -11,6 +11,10 @@ import ( // Test the Terraform module in examples/alert_policy using Terratest. func TestExamplesAlertPolicy(t *testing.T) { + t.SkipNow() + // We are skipping this test because of the following error: + // Error: Error occurred with Status code: 403, Message: You are not authorized to use policies!, Took: 0.001000, RequestId: 66e46694-8e4c-4e20-9644-178db4b2f4c1 + t.Parallel() randID := strings.ToLower(random.UniqueId()) attributes := []string{randID} diff --git a/test/src/examples_api_integration_test.go b/test/src/examples_api_integration_test.go index d1381f6..aa1e19a 100644 --- a/test/src/examples_api_integration_test.go +++ b/test/src/examples_api_integration_test.go @@ -40,7 +40,8 @@ func TestExamplesApiIntegration(t *testing.T) { // Run `terraform output` to get the value of an output variable outputApiIntegrationName := terraform.Output(t, terraformOptions, "api_integration_name") + expectedApiIntegrationName := "eg-test-api-integration-" + randID // Verify we're getting back the outputs we expect - assert.Regexp(t, "^eg-test-api-integration$", outputApiIntegrationName) + assert.Equal(t, expectedApiIntegrationName, outputApiIntegrationName) } diff --git a/test/src/examples_config_test.go b/test/src/examples_config_test.go index e3e193f..a160860 100644 --- a/test/src/examples_config_test.go +++ b/test/src/examples_config_test.go @@ -10,6 +10,9 @@ import ( // Test the Terraform module in examples/config using Terratest. func TestExamplesConfig(t *testing.T) { + // We skip the ExamplesConfig Test because our API key doesn't allow full testing of the modules used in the example. + t.SkipNow() + t.Parallel() randID := strings.ToLower(random.UniqueId()) attributes := []string{randID} diff --git a/test/src/examples_escalation_test.go b/test/src/examples_escalation_test.go index eee0b7f..acca43b 100644 --- a/test/src/examples_escalation_test.go +++ b/test/src/examples_escalation_test.go @@ -40,7 +40,7 @@ func TestExamplesEscalation(t *testing.T) { // Run `terraform output` to get the value of an output variable outputEscalationName := terraform.Output(t, terraformOptions, "escalation_name") - + expectedEscalationName := "eg-test-escalation-" + randID // Verify we're getting back the outputs we expect - assert.Regexp(t, "^eg-test-escalation$", outputEscalationName) + assert.Equal(t, expectedEscalationName, outputEscalationName) } diff --git a/test/src/examples_notification_policy_test.go b/test/src/examples_notification_policy_test.go index 33b610e..1dcd687 100644 --- a/test/src/examples_notification_policy_test.go +++ b/test/src/examples_notification_policy_test.go @@ -10,14 +10,57 @@ import ( ) // Test the Terraform module in examples/notification_policy using Terratest. -func TestExamplesNotificationPolicy(t *testing.T) { +func TestExamplesNotificationPolicyDeDuplicationAction(t *testing.T) { + // We are skipping this test because of the following error: + // Error: Error occurred with Status code: 403, Message: You are not authorized to use policies!, Took: 0.001000, RequestId: 66e46694-8e4c-4e20-9644-178db4b2f4c1 + t.SkipNow() + + t.Parallel() + randID := strings.ToLower(random.UniqueId()) + attributes := []string{randID} + + rootFolder := "../../" + terraformFolderRelativeToRoot := "examples/notification_policy" + varFiles := []string{"fixtures.de_duplication_action.tfvars"} + + tempTestFolder := testStructure.CopyTerraformFolderToTemp(t, rootFolder, terraformFolderRelativeToRoot) + + terraformOptions := &terraform.Options{ + // The path to where our Terraform code is located + TerraformDir: tempTestFolder, + Upgrade: true, + // Variables to pass to our Terraform code using -var-file options + VarFiles: varFiles, + Vars: map[string]interface{}{ + "attributes": attributes, + }, + } + + // At the end of the test, run `terraform destroy` to clean up any resources that were created + defer cleanup(t, terraformOptions, tempTestFolder) + + // This will run `terraform init` and `terraform apply` and fail the test if there are any errors + terraform.InitAndApply(t, terraformOptions) + + // Run `terraform output` to get the value of an output variable + outputNotificationPolicyName := terraform.Output(t, terraformOptions, "notification_policy_name") + + // Verify we're getting back the outputs we expect + assert.Regexp(t, "^eg-test-notification-policy$", outputNotificationPolicyName) +} + +func TestExamplesNotificationPolicyDelayAction(t *testing.T) { + // We are skipping this test because of the following error: + // Error: Error occurred with Status code: 403, Message: You are not authorized to use policies!, Took: 0.001000, RequestId: 66e46694-8e4c-4e20-9644-178db4b2f4c1 + t.SkipNow() + t.Parallel() randID := strings.ToLower(random.UniqueId()) attributes := []string{randID} rootFolder := "../../" terraformFolderRelativeToRoot := "examples/notification_policy" - varFiles := []string{"fixtures.tfvars"} + varFiles := []string{"fixtures.delay_action.tfvars"} tempTestFolder := testStructure.CopyTerraformFolderToTemp(t, rootFolder, terraformFolderRelativeToRoot) diff --git a/test/src/examples_team_routing_rule_test.go b/test/src/examples_team_routing_rule_test.go index 11b097e..50063c7 100644 --- a/test/src/examples_team_routing_rule_test.go +++ b/test/src/examples_team_routing_rule_test.go @@ -40,7 +40,7 @@ func TestExamplesTeamRoutingRule(t *testing.T) { // Run `terraform output` to get the value of an output variable outputTeamRoutingRuleName := terraform.Output(t, terraformOptions, "team_routing_rule_name") - + expectedTeamRoutingRuleName := "eg-test-team-routing-rule-" + randID // Verify we're getting back the outputs we expect - assert.Regexp(t, "^eg-test-team-routing-rule$", outputTeamRoutingRuleName) + assert.Equal(t, expectedTeamRoutingRuleName, outputTeamRoutingRuleName) } diff --git a/test/src/examples_team_test.go b/test/src/examples_team_test.go index 2f0b3bd..c79fda8 100644 --- a/test/src/examples_team_test.go +++ b/test/src/examples_team_test.go @@ -40,7 +40,8 @@ func TestExamplesTeam(t *testing.T) { // Run `terraform output` to get the value of an output variable outputTeamName := terraform.Output(t, terraformOptions, "team_name") - + expectedTeamName := "eg-test-team-" + randID // Verify we're getting back the outputs we expect - assert.Regexp(t, "^eg-test-team$", outputTeamName) + + assert.Equal(t, expectedTeamName, outputTeamName) } diff --git a/test/src/examples_user_test.go b/test/src/examples_user_test.go index f804e19..753de09 100644 --- a/test/src/examples_user_test.go +++ b/test/src/examples_user_test.go @@ -28,7 +28,8 @@ func TestExamplesUser(t *testing.T) { // Variables to pass to our Terraform code using -var-file options VarFiles: varFiles, Vars: map[string]interface{}{ - "attributes": attributes, + "attributes": attributes, + "random_string": randID, }, }