Skip to content

Commit e9b71f6

Browse files
manual cleanup of test resources
1 parent bf89086 commit e9b71f6

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

internal/services/account_member/resource_test.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,7 @@ func testSweepCloudflareAccountMembers(r string) error {
9595
for _, resourceGroup := range resourceGroups.Result {
9696
// Only sweep test resource groups with names matching test patterns
9797
if utils.ShouldSweepResource(resourceGroup.Name) {
98-
_, err := client2.IAM.ResourceGroups.Delete(ctx, resourceGroup.ID, iam.ResourceGroupDeleteParams{
99-
AccountID: cloudflarev6.String(accountID),
100-
})
98+
err = deleteDomainGroup(accountID, resourceGroup.ID)
10199
if err != nil {
102100
tflog.Error(ctx, fmt.Sprintf("Failed to delete resource group %s: %s", resourceGroup.ID, err))
103101
continue
@@ -429,6 +427,10 @@ func TestAccCloudflareAccountMember_PoliciesAddResourceGroup(t *testing.T) {
429427
},
430428
},
431429
})
430+
431+
//cleanup
432+
deleteDomainGroup(accountID, domainGroupID1)
433+
deleteDomainGroup(accountID, domainGroupID2)
432434
}
433435

434436
func testCloudflareAccountMemberPoliciesConfig(accountID, emailAddress, permgroupId string) string {
@@ -527,3 +529,12 @@ func createDomainGroup(t *testing.T, rnd, accountID, domainID string) string {
527529
}
528530
return response.Result.ID
529531
}
532+
533+
func deleteDomainGroup(accountID, domainID string) error {
534+
ctx := context.Background()
535+
client := acctest.SharedClient()
536+
_, err := client.IAM.ResourceGroups.Delete(ctx, domainID, iam.ResourceGroupDeleteParams{
537+
AccountID: cloudflarev6.String(accountID),
538+
})
539+
return err
540+
}

0 commit comments

Comments
 (0)