diff --git a/terraform/context_apply_test.go b/terraform/context_apply_test.go index 15a1b1e2e..2bc98dc46 100644 --- a/terraform/context_apply_test.go +++ b/terraform/context_apply_test.go @@ -2255,8 +2255,9 @@ func TestContext2Apply_countDecreaseToOneCorrupted(t *testing.T) { if p, diags := ctx.Plan(); diags.HasErrors() { t.Fatalf("diags: %s", diags.Err()) } else { - planStr := legacyPlanComparisonString(ctx.State(), p.Changes) - if got, want := planStr, testTerraformApplyCountDecToOneCorruptedPlanStr; got != want { + got := strings.TrimSpace(legacyPlanComparisonString(ctx.State(), p.Changes)) + want := strings.TrimSpace(testTerraformApplyCountDecToOneCorruptedPlanStr) + if got != want { t.Fatalf("wrong plan result\ngot:\n%s\nwant:\n%s", got, want) } } @@ -2269,7 +2270,7 @@ func TestContext2Apply_countDecreaseToOneCorrupted(t *testing.T) { actual := strings.TrimSpace(state.String()) expected := strings.TrimSpace(testTerraformApplyCountDecToOneCorruptedStr) if actual != expected { - t.Fatalf("wrong result\n\ngot:\n%s\n\nwant:\n%s", actual, expected) + t.Fatalf("wrong final state\n\ngot:\n%s\n\nwant:\n%s", actual, expected) } } diff --git a/terraform/context_test.go b/terraform/context_test.go index 32b2e5068..9e37c1d64 100644 --- a/terraform/context_test.go +++ b/terraform/context_test.go @@ -830,6 +830,11 @@ func legacyDiffComparisonString(changes *plans.Changes) string { resourceKeys := map[string][]string{} var moduleKeys []string for _, rc := range changes.Resources { + if rc.Action == plans.NoOp { + // We won't mention no-op changes here at all, since the old plan + // model we are emulating here didn't have such a concept. + continue + } moduleKey := rc.Addr.Module.String() if _, exists := byModule[moduleKey]; !exists { moduleKeys = append(moduleKeys, moduleKey) diff --git a/terraform/terraform_test.go b/terraform/terraform_test.go index 034d7085c..fa2324fd2 100644 --- a/terraform/terraform_test.go +++ b/terraform/terraform_test.go @@ -466,6 +466,7 @@ aws_instance.foo: const testTerraformApplyCountDecToOneCorruptedStr = ` aws_instance.foo: ID = bar + provider = provider.aws foo = foo type = aws_instance ` @@ -473,16 +474,20 @@ aws_instance.foo: const testTerraformApplyCountDecToOneCorruptedPlanStr = ` DIFF: -DESTROY: aws_instance.foo.0 +DESTROY: aws_instance.foo[0] + + STATE: aws_instance.foo: ID = bar + provider = provider.aws foo = foo type = aws_instance aws_instance.foo.0: ID = baz + provider = provider.aws type = aws_instance `