terraform: tests for ResourceDiff.Empty

This commit is contained in:
Mitchell Hashimoto 2014-06-30 20:56:25 -07:00
parent 5632079f43
commit ff79fa9c9f
2 changed files with 32 additions and 1 deletions

View File

@ -177,7 +177,6 @@ const (
)
// Empty returns true if this diff encapsulates no changes.
// TODO(mitchellh): test
func (d *ResourceDiff) Empty() bool {
if d == nil {
return true

View File

@ -70,6 +70,38 @@ func TestDiff_String(t *testing.T) {
}
}
func TestResourceDiff_Empty(t *testing.T) {
var rd *ResourceDiff
if !rd.Empty() {
t.Fatal("should be empty")
}
rd = new(ResourceDiff)
if !rd.Empty() {
t.Fatal("should be empty")
}
rd = &ResourceDiff{Destroy: true}
if rd.Empty() {
t.Fatal("should not be empty")
}
rd = &ResourceDiff{
Attributes: map[string]*ResourceAttrDiff{
"foo": &ResourceAttrDiff{
New: "bar",
},
},
}
if rd.Empty() {
t.Fatal("should not be empty")
}
}
func TestResourceDiff_RequiresNew(t *testing.T) {
rd := &ResourceDiff{
Attributes: map[string]*ResourceAttrDiff{