Skip to content

Commit

Permalink
Merge pull request #5514 from terraform-providers/acctest_parallel_race
Browse files Browse the repository at this point in the history
Fix parallel acctest race on `Provider`
  • Loading branch information
tombuildsstuff authored Jan 24, 2020
2 parents 4ef3e61 + b9d06e5 commit 92ef7a3
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions azurerm/internal/acceptance/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"math"
"os"
"strconv"
"sync"
"testing"

"github.com/Azure/go-autorest/autorest/azure"
Expand All @@ -17,6 +18,8 @@ import (
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/provider"
)

var once sync.Once

type TestData struct {
// Locations is a set of Azure Regions which should be used for this Test
Locations Regions
Expand Down Expand Up @@ -48,13 +51,15 @@ type TestData struct {

// BuildTestData generates some test data for the given resource
func BuildTestData(t *testing.T, resourceType string, resourceLabel string) TestData {
azureProvider := provider.AzureProvider().(*schema.Provider)
once.Do(func() {
azureProvider := provider.AzureProvider().(*schema.Provider)

AzureProvider = azureProvider
SupportedProviders = map[string]terraform.ResourceProvider{
"azurerm": azureProvider,
"azuread": azuread.Provider().(*schema.Provider),
}
AzureProvider = azureProvider
SupportedProviders = map[string]terraform.ResourceProvider{
"azurerm": azureProvider,
"azuread": azuread.Provider().(*schema.Provider),
}
})

env, err := Environment()
if err != nil {
Expand Down

0 comments on commit 92ef7a3

Please sign in to comment.