mirror of
https://github.com/opentffoundation/opentf.git
synced 2026-05-05 00:00:31 -04:00
command/format: take noop changes from lcs
When rendering the diff, the NoOp changes should come from the LCS sequence, rather than the new sequence. The two indexes will not align in many cases, adding the wrong new object or indexing out of bounds.
This commit is contained in:
@@ -3006,6 +3006,49 @@ func TestResourceChange_nestedMap(t *testing.T) {
|
||||
- volume_type = "gp2" -> null
|
||||
}
|
||||
}
|
||||
`,
|
||||
},
|
||||
"in-place sequence update - deletion": {
|
||||
Action: plans.Update,
|
||||
Mode: addrs.ManagedResourceMode,
|
||||
Before: cty.ObjectVal(map[string]cty.Value{
|
||||
"list": cty.ListVal([]cty.Value{
|
||||
cty.ObjectVal(map[string]cty.Value{"attr": cty.StringVal("x")}),
|
||||
cty.ObjectVal(map[string]cty.Value{"attr": cty.StringVal("y")}),
|
||||
}),
|
||||
}),
|
||||
After: cty.ObjectVal(map[string]cty.Value{
|
||||
"list": cty.ListVal([]cty.Value{
|
||||
cty.ObjectVal(map[string]cty.Value{"attr": cty.StringVal("y")}),
|
||||
cty.ObjectVal(map[string]cty.Value{"attr": cty.StringVal("z")}),
|
||||
}),
|
||||
}),
|
||||
RequiredReplace: cty.NewPathSet(),
|
||||
Tainted: false,
|
||||
Schema: &configschema.Block{
|
||||
BlockTypes: map[string]*configschema.NestedBlock{
|
||||
"list": {
|
||||
Block: configschema.Block{
|
||||
Attributes: map[string]*configschema.Attribute{
|
||||
"attr": {
|
||||
Type: cty.String,
|
||||
Required: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
Nesting: configschema.NestingList,
|
||||
},
|
||||
},
|
||||
},
|
||||
ExpectedOutput: ` # test_instance.example will be updated in-place
|
||||
~ resource "test_instance" "example" {
|
||||
~ list {
|
||||
~ attr = "x" -> "y"
|
||||
}
|
||||
~ list {
|
||||
~ attr = "y" -> "z"
|
||||
}
|
||||
}
|
||||
`,
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user