11package resource
22
33import (
4+ "fmt"
5+
46 tfjson "github.com/hashicorp/terraform-json"
57 tftest "github.com/hashicorp/terraform-plugin-test/v2"
68 testing "github.com/mitchellh/go-testing-interface"
@@ -24,7 +26,7 @@ func testStepNewConfig(t testing.T, c TestCase, wd *tftest.WorkingDir, step Test
2426 return err
2527 }
2628 if err := testStepTaint (state , step ); err != nil {
27- t . Fatalf ("Error when tainting resources: %s" , err )
29+ return fmt . Errorf ("Error when tainting resources: %s" , err )
2830 }
2931 }
3032
@@ -58,7 +60,7 @@ func testStepNewConfig(t testing.T, c TestCase, wd *tftest.WorkingDir, step Test
5860 if step .Check != nil {
5961 state .IsBinaryDrivenTest = true
6062 if err := step .Check (state ); err != nil {
61- t . Fatal ( err )
63+ return err
6264 }
6365 }
6466 }
@@ -91,7 +93,7 @@ func testStepNewConfig(t testing.T, c TestCase, wd *tftest.WorkingDir, step Test
9193 if err != nil {
9294 return err
9395 }
94- t . Fatalf ("After applying this test step, the plan was not empty.\n stdout:\n \n %s" , stdout )
96+ return fmt . Errorf ("After applying this test step, the plan was not empty.\n stdout:\n \n %s" , stdout )
9597 }
9698
9799 // do a refresh
@@ -130,7 +132,7 @@ func testStepNewConfig(t testing.T, c TestCase, wd *tftest.WorkingDir, step Test
130132 if err != nil {
131133 return err
132134 }
133- t . Fatalf ("After applying this test step and performing a `terraform refresh`, the plan was not empty.\n stdout\n \n %s" , stdout )
135+ return fmt . Errorf ("After applying this test step and performing a `terraform refresh`, the plan was not empty.\n stdout\n \n %s" , stdout )
134136 }
135137
136138 // ID-ONLY REFRESH
@@ -164,7 +166,7 @@ func testStepNewConfig(t testing.T, c TestCase, wd *tftest.WorkingDir, step Test
164166 // caught a different bug.
165167 if idRefreshCheck != nil {
166168 if err := testIDRefresh (c , t , wd , step , idRefreshCheck ); err != nil {
167- t . Fatalf (
169+ return fmt . Errorf (
168170 "[ERROR] Test: ID-only test failed: %s" , err )
169171 }
170172 }
0 commit comments