@@ -15,7 +15,7 @@ import (
1515 "github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
1616)
1717
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 {
1919 t .Helper ()
2020
2121 err := runProviderCommand (t , func () error {
@@ -27,16 +27,7 @@ func runPostTestDestroy(t testing.T, c TestCase, wd *tftest.WorkingDir, factorie
2727 }
2828
2929 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 {
4031 return err
4132 }
4233 }
@@ -63,7 +54,7 @@ func runNewTest(t testing.T, c TestCase, helper *tftest.Helper) {
6354 }
6455
6556 if ! stateIsEmpty (statePreDestroy ) {
66- err := runPostTestDestroy (t , c , wd , c .ProviderFactories )
57+ err := runPostTestDestroy (t , c , wd , c .ProviderFactories , statePreDestroy )
6758 if err != nil {
6859 t .Fatalf ("Error running post-test destroy, there may be dangling resources: %s" , err .Error ())
6960 }
0 commit comments