Skip to content

Commit

Permalink
Merge pull request hashicorp#355 from hashicorp/auto-configure-acctest
Browse files Browse the repository at this point in the history
auto-configure providers during binary acctests
  • Loading branch information
kmoe authored Mar 15, 2020
2 parents 309005b + 4a500ee commit d3b1ac9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
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

0 comments on commit d3b1ac9

Please sign in to comment.