diff --git a/terraform/diff.go b/terraform/diff.go index e0e097e808..86be4bb5ae 100644 --- a/terraform/diff.go +++ b/terraform/diff.go @@ -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 diff --git a/terraform/diff_test.go b/terraform/diff_test.go index 5234c6aaf3..a9cb8b47b0 100644 --- a/terraform/diff_test.go +++ b/terraform/diff_test.go @@ -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") }