2014-06-05 08:57:06 -05:00
|
|
|
package terraform
|
|
|
|
|
|
|
|
import (
|
2014-06-10 13:22:32 -05:00
|
|
|
"strings"
|
|
|
|
"testing"
|
2014-06-05 08:57:06 -05:00
|
|
|
)
|
|
|
|
|
2014-06-10 13:22:32 -05:00
|
|
|
func TestDiff_String(t *testing.T) {
|
|
|
|
diff := &Diff{
|
|
|
|
Resources: map[string]*ResourceDiff{
|
|
|
|
"nodeA": &ResourceDiff{
|
|
|
|
Attributes: map[string]*ResourceAttrDiff{
|
|
|
|
"foo": &ResourceAttrDiff{
|
|
|
|
Old: "foo",
|
|
|
|
New: "bar",
|
|
|
|
},
|
|
|
|
"bar": &ResourceAttrDiff{
|
|
|
|
Old: "foo",
|
|
|
|
NewComputed: true,
|
|
|
|
},
|
2014-06-10 13:30:54 -05:00
|
|
|
"longfoo": &ResourceAttrDiff{
|
2014-06-10 13:33:59 -05:00
|
|
|
Old: "foo",
|
|
|
|
New: "bar",
|
|
|
|
RequiresNew: true,
|
2014-06-10 13:30:54 -05:00
|
|
|
},
|
2014-06-10 13:22:32 -05:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2014-06-05 08:57:06 -05:00
|
|
|
}
|
2014-06-05 22:17:03 -05:00
|
|
|
|
2014-06-10 13:22:32 -05:00
|
|
|
actual := strings.TrimSpace(diff.String())
|
|
|
|
expected := strings.TrimSpace(diffStrBasic)
|
|
|
|
if actual != expected {
|
|
|
|
t.Fatalf("bad:\n%s", actual)
|
2014-06-05 08:57:06 -05:00
|
|
|
}
|
|
|
|
}
|
2014-06-10 13:22:32 -05:00
|
|
|
|
|
|
|
const diffStrBasic = `
|
2014-06-10 13:37:04 -05:00
|
|
|
CREATE: nodeA
|
2014-06-10 13:30:54 -05:00
|
|
|
bar: "foo" => "<computed>"
|
|
|
|
foo: "foo" => "bar"
|
2014-06-10 13:33:59 -05:00
|
|
|
longfoo: "foo" => "bar" (forces new resource)
|
2014-06-10 13:22:32 -05:00
|
|
|
`
|