mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-28 01:41:48 -06:00
terraform: Diff.DeepCopy test to catch a bug that in copystructure
This was fixed upstream but keeping the test around to prevent regressions.
This commit is contained in:
parent
742af8752b
commit
5053872e82
@ -292,6 +292,10 @@ func (d *ModuleDiff) String() string {
|
||||
return buf.String()
|
||||
}
|
||||
|
||||
func (d *ModuleDiff) GoString() string {
|
||||
return fmt.Sprintf("*%#v", *d)
|
||||
}
|
||||
|
||||
// InstanceDiff is the diff of a resource from some state to another.
|
||||
type InstanceDiff struct {
|
||||
mu sync.Mutex
|
||||
|
@ -115,6 +115,39 @@ func TestModuleDiff_ChangeType(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestDiff_DeepCopy(t *testing.T) {
|
||||
cases := map[string]*Diff{
|
||||
"empty": &Diff{},
|
||||
|
||||
"basic diff": &Diff{
|
||||
Modules: []*ModuleDiff{
|
||||
&ModuleDiff{
|
||||
Path: []string{"root"},
|
||||
Resources: map[string]*InstanceDiff{
|
||||
"aws_instance.foo": &InstanceDiff{
|
||||
Attributes: map[string]*ResourceAttrDiff{
|
||||
"num": &ResourceAttrDiff{
|
||||
Old: "0",
|
||||
New: "2",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for name, tc := range cases {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
dup := tc.DeepCopy()
|
||||
if !reflect.DeepEqual(dup, tc) {
|
||||
t.Fatalf("\n%#v\n\n%#v", dup, tc)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestModuleDiff_Empty(t *testing.T) {
|
||||
diff := new(ModuleDiff)
|
||||
if !diff.Empty() {
|
||||
|
Loading…
Reference in New Issue
Block a user