Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions github/acc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,21 @@ type testAccConfig struct {

var testAccConf *testAccConfig

var testAccProviders map[string]*schema.Provider = map[string]*schema.Provider{
"github": Provider(),
}
Comment on lines +77 to +79
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK we should be getting rid of using testAccProviders the recommended approach is to only use ProviderFactories.

Could you mark this as deprecated?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made the change to do this already (and stashed them), but I'm holding off adding them in to the PR until the actual changes have been reviewed.


// providerFactories are used to instantiate a provider during acceptance testing.
// The factory function will be invoked for every Terraform CLI command executed
// to create a provider server to which the CLI can reattach.
var providerFactories = map[string]func() (*schema.Provider, error){
//nolint:unparam
"github": func() (*schema.Provider, error) {
return Provider(), nil
},
}
var (
providerFactories = map[string]func() (*schema.Provider, error){
//nolint:unparam
"github": func() (*schema.Provider, error) {
return Provider(), nil
},
}
)

func TestMain(m *testing.M) {
authMode := testMode(os.Getenv("GH_TEST_AUTH_MODE"))
Expand Down
24 changes: 0 additions & 24 deletions github/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,9 @@ import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
)

var (
testAccProviders map[string]*schema.Provider
testAccProviderFactories func(providers *[]*schema.Provider) map[string]func() (*schema.Provider, error)
testAccProvider *schema.Provider
)

func init() {
testAccProvider = Provider()
testAccProviders = map[string]*schema.Provider{
"github": testAccProvider,
}
testAccProviderFactories = func(providers *[]*schema.Provider) map[string]func() (*schema.Provider, error) {
return map[string]func() (*schema.Provider, error){
//nolint:unparam
"github": func() (*schema.Provider, error) {
p := Provider()
*providers = append(*providers, p)
return p, nil
},
}
}
}

func TestProvider(t *testing.T) {
t.Run("runs internal validation without error", func(t *testing.T) {
if err := Provider().InternalValidate(); err != nil {
Expand Down
Loading