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
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ DEPRECATED:

* helper/schema: `ResourceData.GetOkExists` will not be removed in the next major version unless a suitable replacement or alternative can be prescribed [GH-350]

BUG FIXES:

* Binary acceptance test driver: auto-configure providers [GH-355]

# 1.8.0 (March 11, 2020)

FEATURES:
Expand Down
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