Skip to content

Commit d11d7df

Browse files
committed
binary acctesting: auto-Configure providers
1 parent d5f3a05 commit d11d7df

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

helper/resource/testing.go

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package resource
22

33
import (
4+
"context"
45
"errors"
56
"flag"
67
"fmt"
@@ -539,11 +540,6 @@ func Test(t TestT, c TestCase) {
539540
t.Fatal("Acceptance tests must be run with the -v flag on tests")
540541
}
541542

542-
// Run the PreCheck if we have it
543-
if c.PreCheck != nil {
544-
c.PreCheck()
545-
}
546-
547543
// get instances of all providers, so we can use the individual
548544
// resources to shim the state during the tests.
549545
providers := make(map[string]*schema.Provider)
@@ -558,6 +554,21 @@ func Test(t TestT, c TestCase) {
558554
providers[name] = p
559555
}
560556

557+
// Auto-configure all providers.
558+
for _, p := range providers {
559+
err = p.Configure(context.Background(), terraform.NewResourceConfigRaw(nil))
560+
if err != nil {
561+
t.Fatal(err)
562+
}
563+
}
564+
565+
// Run the PreCheck if we have it.
566+
// This is done after the auto-configure to allow providers
567+
// to override the default auto-configure parameters.
568+
if c.PreCheck != nil {
569+
c.PreCheck()
570+
}
571+
561572
if acctest.TestHelper == nil {
562573
t.Fatal("Please configure the acctest binary driver")
563574
}

0 commit comments

Comments
 (0)