mirror of
https://github.com/opentofu/opentofu.git
synced 2025-01-16 03:32:54 -06:00
Merge pull request #8167 from hashicorp/b-tainted-no-attrs-still-replaces
terraform: diffs with only tainted set are non-empty
This commit is contained in:
commit
b9f950f1d4
@ -2400,6 +2400,26 @@ func TestSchemaMap_Diff(t *testing.T) {
|
||||
|
||||
Err: false,
|
||||
},
|
||||
|
||||
"tainted in state w/ no attr changes is still a replacement": {
|
||||
Schema: map[string]*Schema{},
|
||||
|
||||
State: &terraform.InstanceState{
|
||||
Attributes: map[string]string{
|
||||
"id": "someid",
|
||||
},
|
||||
Tainted: true,
|
||||
},
|
||||
|
||||
Config: map[string]interface{}{},
|
||||
|
||||
Diff: &terraform.InstanceDiff{
|
||||
Attributes: map[string]*terraform.ResourceAttrDiff{},
|
||||
DestroyTainted: true,
|
||||
},
|
||||
|
||||
Err: false,
|
||||
},
|
||||
}
|
||||
|
||||
for tn, tc := range cases {
|
||||
|
@ -1950,6 +1950,7 @@ func TestContext2Plan_taintDestroyInterpolatedCountRace(t *testing.T) {
|
||||
DIFF:
|
||||
|
||||
DESTROY/CREATE: aws_instance.foo.0
|
||||
type: "" => "aws_instance"
|
||||
|
||||
STATE:
|
||||
|
||||
@ -1961,7 +1962,7 @@ aws_instance.foo.2:
|
||||
ID = bar
|
||||
`)
|
||||
if actual != expected {
|
||||
t.Fatalf("bad:\n%s", actual)
|
||||
t.Fatalf("[%d] bad:\n%s\nexpected:\n%s\n", i, actual, expected)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -361,7 +361,7 @@ func (d *InstanceDiff) Empty() bool {
|
||||
|
||||
d.mu.Lock()
|
||||
defer d.mu.Unlock()
|
||||
return !d.Destroy && len(d.Attributes) == 0
|
||||
return !d.Destroy && !d.DestroyTainted && len(d.Attributes) == 0
|
||||
}
|
||||
|
||||
func (d *InstanceDiff) GoString() string {
|
||||
|
@ -27,6 +27,19 @@ func TestDiffEmpty(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestDiffEmpty_taintedIsNotEmpty(t *testing.T) {
|
||||
diff := new(Diff)
|
||||
|
||||
mod := diff.AddModule(rootModulePath)
|
||||
mod.Resources["nodeA"] = &InstanceDiff{
|
||||
DestroyTainted: true,
|
||||
}
|
||||
|
||||
if diff.Empty() {
|
||||
t.Fatal("should not be empty, since DestroyTainted was set")
|
||||
}
|
||||
}
|
||||
|
||||
func TestModuleDiff_ChangeType(t *testing.T) {
|
||||
cases := []struct {
|
||||
Diff *ModuleDiff
|
||||
|
Loading…
Reference in New Issue
Block a user