diff --git a/terraform/diff.go b/terraform/diff.go index e0e097e80..86be4bb5a 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 5234c6aaf..a9cb8b47b 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") }