terraform: tests for ResourceDiff.Empty
This commit is contained in:
parent
5632079f43
commit
ff79fa9c9f
|
@ -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
|
||||
|
|
|
@ -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{
|
||||
|
|
Loading…
Reference in New Issue