Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

auto-configure providers during binary acctests #355

Merged
merged 2 commits into from
Mar 15, 2020
Merged
Changes from 1 commit
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
25 changes: 20 additions & 5 deletions helper/resource/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -556,11 +556,6 @@ func Test(t TestT, c TestCase) {
return
}

// Run the PreCheck if we have it
if c.PreCheck != nil {
c.PreCheck()
}

// get instances of all providers, so we can use the individual
// resources to shim the state during the tests.
providers := make(map[string]terraform.ResourceProvider)
Expand All @@ -573,9 +568,29 @@ func Test(t TestT, c TestCase) {
}

if acctest.TestHelper != nil && c.DisableBinaryDriver == false {
// auto-configure all providers
for _, p := range providers {
err = p.Configure(terraform.NewResourceConfigRaw(nil))
if err != nil {
t.Fatal(err)
}
}

// Run the PreCheck if we have it.
// This is done after the auto-configure to allow providers
// to override the default auto-configure parameters.
if c.PreCheck != nil {
c.PreCheck()
}

// inject providers for ImportStateVerify
RunNewTest(t.(*testing.T), c, providers)
return
} else {
// run the PreCheck if we have it
if c.PreCheck != nil {
c.PreCheck()
}
}

providerResolver, err := testProviderResolver(c)
Expand Down