Add a core test for InstanceDiff.Same

This commit is contained in:
James Bardin 2016-06-16 18:37:11 -04:00
parent a3e2c99219
commit f4ef16a84b
1 changed files with 41 additions and 0 deletions

View File

@ -525,6 +525,47 @@ func TestInstanceDiffSame(t *testing.T) {
"",
},
// Computed sets may not contain all fields in the original diff, and
// because multiple entries for the same set can compute to the same
// hash before the values are computed or interpolated, the overall
// count can change as well.
{
&InstanceDiff{
Attributes: map[string]*ResourceAttrDiff{
"foo.#": &ResourceAttrDiff{
Old: "0",
New: "1",
},
"foo.~35964334.bar": &ResourceAttrDiff{
Old: "",
New: "${var.foo}",
},
},
},
&InstanceDiff{
Attributes: map[string]*ResourceAttrDiff{
"foo.#": &ResourceAttrDiff{
Old: "0",
New: "2",
},
"foo.87654323.bar": &ResourceAttrDiff{
Old: "",
New: "12",
},
"foo.87654325.bar": &ResourceAttrDiff{
Old: "",
New: "12",
},
"foo.87654325.baz": &ResourceAttrDiff{
Old: "",
New: "12",
},
},
},
true,
"",
},
// In a DESTROY/CREATE scenario, the plan diff will be run against the
// state of the old instance, while the apply diff will be run against an
// empty state (because the state is cleared when the destroy runs.)