From 88e911af458f809fd4d50948b74f78dd04744fd5 Mon Sep 17 00:00:00 2001 From: James Bardin Date: Thu, 15 Mar 2018 14:50:58 -0400 Subject: [PATCH] fix a provisionerFail test which was incorrect The provisionerFail_createBeforeDestroy test was verifying the incorrect output. The create_before_destroy instance in the state has an ID of "bar" with require_new="abc", and a new instance would get an ID of "foo" with require_new="xyz". The existing test was expecting the following state: aws_instance.bar: (1 deposed) ID = bar provider = provider.aws require_new = abc Deposed ID 1 = foo (tainted) Which showed "bar" still the primary instance in the state, with the new instance "foo" as being the deposed instance, though properly tainted. The new output is: aws_instance.bar: (tainted) (1 deposed) ID = foo provider = provider.aws require_new = xyz type = aws_instance Deposed ID 1 = bar Showing the new "foo instance as being the primary instance in the state, with "bar" as the deposed instance. --- terraform/context_apply_test.go | 2 +- terraform/terraform_test.go | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/terraform/context_apply_test.go b/terraform/context_apply_test.go index 69da40cfc..f53bae1d9 100644 --- a/terraform/context_apply_test.go +++ b/terraform/context_apply_test.go @@ -4482,7 +4482,7 @@ func TestContext2Apply_provisionerFail_createBeforeDestroy(t *testing.T) { actual := strings.TrimSpace(state.String()) expected := strings.TrimSpace(testTerraformApplyProvisionerFailCreateBeforeDestroyStr) if actual != expected { - t.Fatalf("bad: \n%s", actual) + t.Fatalf("expected:\n%s\n:got\n%s", expected, actual) } } diff --git a/terraform/terraform_test.go b/terraform/terraform_test.go index 2deb44153..26c3f9880 100644 --- a/terraform/terraform_test.go +++ b/terraform/terraform_test.go @@ -636,11 +636,12 @@ const testTerraformApplyProvisionerFailCreateNoIdStr = ` ` const testTerraformApplyProvisionerFailCreateBeforeDestroyStr = ` -aws_instance.bar: (1 deposed) - ID = bar +aws_instance.bar: (tainted) (1 deposed) + ID = foo provider = provider.aws - require_new = abc - Deposed ID 1 = foo (tainted) + require_new = xyz + type = aws_instance + Deposed ID 1 = bar ` const testTerraformApplyProvisionerResourceRefStr = `