@@ -15,7 +15,7 @@ import (
15
15
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
16
16
)
17
17
18
- func runPostTestDestroy (t testing.T , c TestCase , wd * tftest.WorkingDir , factories map [string ]func () (* schema.Provider , error )) error {
18
+ func runPostTestDestroy (t testing.T , c TestCase , wd * tftest.WorkingDir , factories map [string ]func () (* schema.Provider , error ), statePreDestroy * terraform. State ) error {
19
19
t .Helper ()
20
20
21
21
err := runProviderCommand (t , func () error {
@@ -27,16 +27,7 @@ func runPostTestDestroy(t testing.T, c TestCase, wd *tftest.WorkingDir, factorie
27
27
}
28
28
29
29
if c .CheckDestroy != nil {
30
- var statePostDestroy * terraform.State
31
- err := runProviderCommand (t , func () error {
32
- statePostDestroy = getState (t , wd )
33
- return nil
34
- }, wd , factories )
35
- if err != nil {
36
- return err
37
- }
38
-
39
- if err := c .CheckDestroy (statePostDestroy ); err != nil {
30
+ if err := c .CheckDestroy (statePreDestroy ); err != nil {
40
31
return err
41
32
}
42
33
}
@@ -63,7 +54,7 @@ func runNewTest(t testing.T, c TestCase, helper *tftest.Helper) {
63
54
}
64
55
65
56
if ! stateIsEmpty (statePreDestroy ) {
66
- err := runPostTestDestroy (t , c , wd , c .ProviderFactories )
57
+ err := runPostTestDestroy (t , c , wd , c .ProviderFactories , statePreDestroy )
67
58
if err != nil {
68
59
t .Fatalf ("Error running post-test destroy, there may be dangling resources: %s" , err .Error ())
69
60
}
0 commit comments