From da20613deb5211bcd4232fb6c5d6f17fe756df4e Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Fri, 21 Sep 2018 10:52:11 -0700 Subject: [PATCH] core: Fix TestContext2Apply_provisionerDestroyRefInvalid This test was relying on an odd definition of "invalid" from prior versions of Terraform, where it would be an error to access an attribute that exists as part of the resource type schema but the provider implementation neglected to set it. This was an implementation detail though, caused by the flatmap representation and the fact that core itself didn't have access to the schema to do static validation. Now the original usage returns a null value because the "value" attribute is defined, and so we need a new test fixture that accesses an attribute that is not defined in the schema at all. --- terraform/context_apply_test.go | 2 +- .../apply-provisioner-destroy-ref-invalid/main.tf | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 terraform/test-fixtures/apply-provisioner-destroy-ref-invalid/main.tf diff --git a/terraform/context_apply_test.go b/terraform/context_apply_test.go index 334c285b0a..47b2987691 100644 --- a/terraform/context_apply_test.go +++ b/terraform/context_apply_test.go @@ -5396,7 +5396,7 @@ func TestContext2Apply_provisionerDestroyRef(t *testing.T) { // Test that a destroy provisioner referencing an invalid key errors. func TestContext2Apply_provisionerDestroyRefInvalid(t *testing.T) { - m := testModule(t, "apply-provisioner-destroy-ref") + m := testModule(t, "apply-provisioner-destroy-ref-invalid") p := testProvider("aws") pr := testProvisioner() p.ApplyFn = testApplyFn diff --git a/terraform/test-fixtures/apply-provisioner-destroy-ref-invalid/main.tf b/terraform/test-fixtures/apply-provisioner-destroy-ref-invalid/main.tf new file mode 100644 index 0000000000..fb4a96b100 --- /dev/null +++ b/terraform/test-fixtures/apply-provisioner-destroy-ref-invalid/main.tf @@ -0,0 +1,12 @@ +resource "aws_instance" "bar" { + value = "hello" +} + +resource "aws_instance" "foo" { + foo = "bar" + + provisioner "shell" { + command = aws_instance.bar.does_not_exist + when = "destroy" + } +}