terraform: Diff.Empty should be true for nil Diff

This commit is contained in:
Mitchell Hashimoto 2016-09-12 19:37:19 -06:00
parent 0fe51b334c
commit 50afee2a30
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
2 changed files with 10 additions and 1 deletions

View File

@ -72,6 +72,10 @@ func (d *Diff) RootModule() *ModuleDiff {
// Empty returns true if the diff has no changes.
func (d *Diff) Empty() bool {
if d == nil {
return true
}
for _, m := range d.Modules {
if !m.Empty() {
return false

View File

@ -7,7 +7,12 @@ import (
)
func TestDiffEmpty(t *testing.T) {
diff := new(Diff)
var diff *Diff
if !diff.Empty() {
t.Fatal("should be empty")
}
diff = new(Diff)
if !diff.Empty() {
t.Fatal("should be empty")
}