Skip to content

Commit 987102c

Browse files
committed
binary acctesting: auto-Configure providers
1 parent 309005b commit 987102c

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

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)