Skip to content

Commit

Permalink
Fix test so it doesn't fail randomly
Browse files Browse the repository at this point in the history
  • Loading branch information
julienduchesne committed Mar 20, 2024
1 parent 5e3e192 commit 187791d
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func TestAccGrafanaServiceAccountFromCloud_MigrateFrom213(t *testing.T) {
Steps: []resource.TestStep{
// Apply with 2.13.0 provider
{
Config: testAccGrafanaServiceAccountFromCloud(slug, slug, false),
Config: testAccGrafanaServiceAccountWithStackFolder(slug, slug, true),
ExternalProviders: map[string]resource.ExternalProvider{
"grafana": {
VersionConstraint: "=2.13.0",
Expand All @@ -99,10 +99,15 @@ func TestAccGrafanaServiceAccountFromCloud_MigrateFrom213(t *testing.T) {
},
// Apply with latest provider
{
Config: testAccGrafanaServiceAccountFromCloud(slug, slug, false),
Config: testAccGrafanaServiceAccountWithStackFolder(slug, slug, true),
Check: check,
ProtoV5ProviderFactories: testutils.ProtoV5ProviderFactories,
},
// Destroy the folder
{
Config: testAccGrafanaServiceAccountWithStackFolder(slug, slug, false),
ProtoV5ProviderFactories: testutils.ProtoV5ProviderFactories,
},
},
})
}
Expand All @@ -121,18 +126,23 @@ func testAccGrafanaServiceAccountFromCloud(name, slug string, disabled bool) str
service_account_id = grafana_cloud_stack_service_account.management.id
name = "management-sa-token"
}
`, disabled)
}

func testAccGrafanaServiceAccountWithStackFolder(name, slug string, withFolder bool) string {
return testAccGrafanaServiceAccountFromCloud(name, slug, false) + fmt.Sprintf(`
provider "grafana" {
alias = "stack"
auth = grafana_cloud_stack_service_account_token.management_token.key
url = grafana_cloud_stack.test.url
}
resource "grafana_folder" "test" {
count = %t ? 1 : 0
provider = grafana.stack
title = "test"
}
`, disabled)
`, withFolder)
}

func testAccGrafanaAuthCheckServiceAccounts(stack *gcom.FormattedApiInstance, expectedSAs []string) resource.TestCheckFunc {
Expand Down

0 comments on commit 187791d

Please sign in to comment.