Skip to content

Commit d3b1ac9

Browse files
authored
Merge pull request #355 from hashicorp/auto-configure-acctest
auto-configure providers during binary acctests
2 parents 309005b + 4a500ee commit d3b1ac9

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ DEPRECATED:
44

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

7+
BUG FIXES:
8+
9+
* Binary acceptance test driver: auto-configure providers [GH-355]
10+
711
# 1.8.0 (March 11, 2020)
812

913
FEATURES:

helper/resource/testing.go

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -556,11 +556,6 @@ func Test(t TestT, c TestCase) {
556556
return
557557
}
558558

559-
// Run the PreCheck if we have it
560-
if c.PreCheck != nil {
561-
c.PreCheck()
562-
}
563-
564559
// get instances of all providers, so we can use the individual
565560
// resources to shim the state during the tests.
566561
providers := make(map[string]terraform.ResourceProvider)
@@ -573,9 +568,29 @@ func Test(t TestT, c TestCase) {
573568
}
574569

575570
if acctest.TestHelper != nil && c.DisableBinaryDriver == false {
571+
// auto-configure all providers
572+
for _, p := range providers {
573+
err = p.Configure(terraform.NewResourceConfigRaw(nil))
574+
if err != nil {
575+
t.Fatal(err)
576+
}
577+
}
578+
579+
// Run the PreCheck if we have it.
580+
// This is done after the auto-configure to allow providers
581+
// to override the default auto-configure parameters.
582+
if c.PreCheck != nil {
583+
c.PreCheck()
584+
}
585+
576586
// inject providers for ImportStateVerify
577587
RunNewTest(t.(*testing.T), c, providers)
578588
return
589+
} else {
590+
// run the PreCheck if we have it
591+
if c.PreCheck != nil {
592+
c.PreCheck()
593+
}
579594
}
580595

581596
providerResolver, err := testProviderResolver(c)

0 commit comments

Comments
 (0)