Skip to content

Commit 2c74b97

Browse files
paddycarverPaddy
authored andcommitted
Use pre-apply state when destroying.
We want to use the pre-apply state when destroying for checks when TestStep.Destroy is true, because the state after is going to be empty. This preserves the behavior of v1 and before, which providers may be relying on.
1 parent 33a47c7 commit 2c74b97

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

helper/resource/testing_new_config.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,14 @@ func testStepNewConfig(t testing.T, c TestCase, wd *tftest.WorkingDir, step Test
9898
// Run any configured checks
9999
if step.Check != nil {
100100
state.IsBinaryDrivenTest = true
101-
if err := step.Check(state); err != nil {
102-
return err
101+
if step.Destroy {
102+
if err := step.Check(stateBeforeApplication); err != nil {
103+
return fmt.Errorf("Check failed: %w", err)
104+
}
105+
} else {
106+
if err := step.Check(state); err != nil {
107+
return fmt.Errorf("Check failed: %w", err)
108+
}
103109
}
104110
}
105111
}

0 commit comments

Comments
 (0)