Skip to content

Commit

Permalink
Cloud: Fix SM installation test (#1568)
Browse files Browse the repository at this point in the history
It crashes because it's missing the region in those API calls
  • Loading branch information
julienduchesne authored May 14, 2024
1 parent b761830 commit 9bb8e44
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -224,16 +224,16 @@ func testAccCloudAccessPolicyTokenCheckDestroy(region string, a *gcom.AuthToken)
}
}

func testAccDeleteExistingAccessPolicies(t *testing.T, prefix string) {
func testAccDeleteExistingAccessPolicies(t *testing.T, region, prefix string) {
client := testutils.Provider.Meta().(*common.Client).GrafanaCloudAPI
resp, _, err := client.AccesspoliciesAPI.GetAccessPolicies(context.Background()).Execute()
resp, _, err := client.AccesspoliciesAPI.GetAccessPolicies(context.Background()).Region(region).Execute()
if err != nil {
t.Error(err)
}

for _, ap := range resp.Items {
if strings.HasPrefix(ap.Name, prefix) {
_, _, err := client.AccesspoliciesAPI.DeleteAccessPolicy(context.Background(), *ap.Id).XRequestId(cloud.ClientRequestID()).Execute()
_, _, err := client.AccesspoliciesAPI.DeleteAccessPolicy(context.Background(), *ap.Id).XRequestId(cloud.ClientRequestID()).Region(region).Execute()
if err != nil {
t.Error(err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestAccSyntheticMonitoringInstallation(t *testing.T) {
stackSlug := GetRandomStackName(stackPrefix)

accessPolicyPrefix := "testsminstall-"
testAccDeleteExistingAccessPolicies(t, accessPolicyPrefix)
testAccDeleteExistingAccessPolicies(t, region, accessPolicyPrefix)
accessPolicyName := accessPolicyPrefix + acctest.RandStringFromCharSet(5, acctest.CharSetAlphaNum)

resource.ParallelTest(t, resource.TestCase{
Expand Down

0 comments on commit 9bb8e44

Please sign in to comment.