Skip to content

Commit db4b2a3

Browse files
authored
test: use unique RG for test (#535)
1 parent 4d612ff commit db4b2a3

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

tests/other_test.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88

99
/* "encoding/json" */
1010

11+
"github.com/google/uuid"
1112
"github.com/stretchr/testify/assert"
1213
"github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/testschematic"
1314
)
@@ -71,7 +72,13 @@ func TestFSCloudInSchematics(t *testing.T) {
7172
assert.Nil(t, err, "This should not have errored")
7273
}
7374

75+
func generateUniqueResourceGroupName(baseName string) string {
76+
id := uuid.New().String()[:8] // Shorten UUID for readability
77+
return fmt.Sprintf("%s-%s", baseName, id)
78+
}
79+
7480
func setupSecurityEnforcedOptions(t *testing.T, prefix string) *testschematic.TestSchematicOptions {
81+
7582
options := testschematic.TestSchematicOptionsDefault(&testschematic.TestSchematicOptions{
7683
Testing: t,
7784
Prefix: prefix,
@@ -86,6 +93,8 @@ func setupSecurityEnforcedOptions(t *testing.T, prefix string) *testschematic.Te
8693
WaitJobCompleteMinutes: 360,
8794
})
8895

96+
uniqueResourceGroup := generateUniqueResourceGroupName(options.Prefix)
97+
8998
serviceCredentialSecrets := []map[string]interface{}{
9099
{
91100
"secret_group_name": fmt.Sprintf("%s-secret-group", options.Prefix),
@@ -156,7 +165,7 @@ func setupSecurityEnforcedOptions(t *testing.T, prefix string) *testschematic.Te
156165
{Name: "ibmcloud_api_key", Value: options.RequiredEnvironmentVars["TF_VAR_ibmcloud_api_key"], DataType: "string", Secure: true},
157166
{Name: "prefix", Value: options.Prefix, DataType: "string"},
158167
{Name: "region", Value: "us-south", DataType: "string"},
159-
{Name: "existing_resource_group_name", Value: resourceGroup, DataType: "string"},
168+
{Name: "existing_resource_group_name", Value: uniqueResourceGroup, DataType: "string"},
160169
{Name: "existing_kms_instance_crn", Value: permanentResources["hpcs_south_crn"], DataType: "string"},
161170
{Name: "access_tags", Value: permanentResources["accessTags"], DataType: "list(string)"},
162171
{Name: "resource_tags", Value: options.Tags, DataType: "list(string)"},

0 commit comments

Comments
 (0)