Skip to content

Commit

Permalink
acctest: disabling Binary Testing for now
Browse files Browse the repository at this point in the history
This requires further co-ordination with the Plugin SDK team, since we shouldn't
require adding a TestMain to each package - as such we're going to feature-toggle
this off for the moment.
  • Loading branch information
tombuildsstuff committed Jul 6, 2020
1 parent 0fa4bc8 commit 993afe3
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 20 deletions.
23 changes: 3 additions & 20 deletions azurerm/internal/acceptance/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,21 @@ import (
"math"
"os"
"strconv"
"sync"
"testing"

"github.com/Azure/go-autorest/autorest/azure"
binarytestfuntime "github.com/hashicorp/terraform-plugin-sdk/acctest"
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
"github.com/terraform-providers/terraform-provider-azuread/azuread"
"github.com/terraform-providers/terraform-provider-azuread/azuread/helpers/tf"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/features"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/provider"
)

var once sync.Once

func init() {
// unit testing
if os.Getenv("TF_ACC") == "" {
return
}

once.Do(func() {
azureProvider := provider.TestAzureProvider().(*schema.Provider)

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

binarytestfuntime.UseBinaryDriver("azurerm", provider.TestAzureProvider)
binarytestfuntime.UseBinaryDriver("azuread", azuread.Provider)
})
EnsureProvidersAreInited()
}

type TestData struct {
Expand Down Expand Up @@ -72,6 +53,8 @@ type TestData struct {

// BuildTestData generates some test data for the given resource
func BuildTestData(t *testing.T, resourceType string, resourceLabel string) TestData {
EnsureProvidersAreInited()

env, err := Environment()
if err != nil {
t.Fatalf("Error retrieving Environment: %+v", err)
Expand Down
31 changes: 31 additions & 0 deletions azurerm/internal/acceptance/providers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package acceptance

import (
"os"
"sync"

"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
"github.com/terraform-providers/terraform-provider-azuread/azuread"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/provider"
)

var once sync.Once

func EnsureProvidersAreInited() {
// NOTE: (@tombuildsstuff) - opting-out of Binary Testing for the moment
os.Setenv("TF_DISABLE_BINARY_TESTING", "true")

once.Do(func() {
azureProvider := provider.TestAzureProvider().(*schema.Provider)

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

//binarytestfuntime.UseBinaryDriver("azurerm", provider.TestAzureProvider)
//binarytestfuntime.UseBinaryDriver("azuread", azuread.Provider)
})
}

0 comments on commit 993afe3

Please sign in to comment.