Skip to content

Commit 6a5574a

Browse files
committedMar 9, 2025·
Final test I think :corssing-fingers: let the idempotent tests pass please
1 parent 69e024c commit 6a5574a

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed
 

‎internal/provider/system_resource_test.go

+13-9
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,13 @@ func testAccCheckSystemDestroy(s *terraform.State) error {
134134
}
135135

136136
func TestAccSystemResource(t *testing.T) {
137-
firstName := acctest.RandString(10)
138-
secondName := acctest.RandString(10)
139-
thirdName := acctest.RandString(10)
140-
description := "This is a test description"
141-
updatedDescription := "This is an updated description"
137+
// Generate a unique prefix for all resources in this test
138+
rPrefix := acctest.RandString(8)
139+
firstName := fmt.Sprintf("first-%s-%s", rPrefix, acctest.RandString(5))
140+
secondName := fmt.Sprintf("second-%s-%s", rPrefix, acctest.RandString(5))
141+
thirdName := fmt.Sprintf("third-%s-%s", rPrefix, acctest.RandString(5))
142+
description := fmt.Sprintf("Test description %s", rPrefix)
143+
updatedDescription := fmt.Sprintf("Updated description %s", rPrefix)
142144

143145
resource.Test(t, resource.TestCase{
144146
PreCheck: func() { ctrlacctest.PreCheck(t) },
@@ -209,7 +211,7 @@ func TestAccSystemResource(t *testing.T) {
209211
resource.TestCheckNoResourceAttr("ctrlplane_system.test", "description"),
210212
),
211213
},
212-
// Update and Read testing - add description back
214+
// Update and Read testing - add description
213215
{
214216
Config: testAccSystemResourceConfig(thirdName, thirdName, &updatedDescription),
215217
Check: resource.ComposeAggregateTestCheckFunc(
@@ -404,9 +406,11 @@ resource "ctrlplane_system" "second" {
404406
}
405407

406408
func TestAccSystemResourceSameNameDifferentSlug(t *testing.T) {
407-
sharedName := acctest.RandString(10)
408-
firstSlug := fmt.Sprintf("%s-first", sharedName)
409-
secondSlug := fmt.Sprintf("%s-second", sharedName)
409+
// Generate a truly unique name and slugs
410+
rPrefix := acctest.RandString(8)
411+
sharedName := fmt.Sprintf("shared-%s-%s", rPrefix, acctest.RandString(5))
412+
firstSlug := fmt.Sprintf("first-%s-%s", rPrefix, acctest.RandString(5))
413+
secondSlug := fmt.Sprintf("second-%s-%s", rPrefix, acctest.RandString(5))
410414

411415
resource.Test(t, resource.TestCase{
412416
PreCheck: func() { ctrlacctest.PreCheck(t) },

0 commit comments

Comments
 (0)
Please sign in to comment.