From d9c137555f5ce0898071b2443c9f725e7af02b46 Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Sat, 21 May 2016 13:00:46 -0700 Subject: [PATCH] core: test to prove that data diffs are broken Apparently there's been a regression in the creation of data resource diffs: they aren't showing up in the plan at all. As a first step to fixing this, this is an intentionally-failing test that proves it's broken. --- terraform/context_plan_test.go | 31 +++++++++++++++++++ .../plan-computed-data-resource/main.tf | 8 +++++ 2 files changed, 39 insertions(+) create mode 100644 terraform/test-fixtures/plan-computed-data-resource/main.tf diff --git a/terraform/context_plan_test.go b/terraform/context_plan_test.go index 58ae89124..f7e8cf5d0 100644 --- a/terraform/context_plan_test.go +++ b/terraform/context_plan_test.go @@ -864,6 +864,37 @@ func TestContext2Plan_computed(t *testing.T) { } } +func TestContext2Plan_computedDataResource(t *testing.T) { + m := testModule(t, "plan-computed-data-resource") + p := testProvider("aws") + p.DiffFn = testDiffFn + ctx := testContext2(t, &ContextOpts{ + Module: m, + Providers: map[string]ResourceProviderFactory{ + "aws": testProviderFuncFixed(p), + }, + }) + + plan, err := ctx.Plan() + if err != nil { + t.Fatalf("err: %s", err) + } + + if got := len(plan.Diff.Modules); got != 1 { + t.Fatalf("got %d modules; want 1", got) + } + + moduleDiff := plan.Diff.Modules[0] + + if _, ok := moduleDiff.Resources["aws_instance.foo"]; !ok { + t.Fatalf("missing diff for aws_instance.foo") + } + _, ok := moduleDiff.Resources["data.aws_vpc.bar"] + if !ok { + t.Fatalf("missing diff for data.aws_vpc.bar") + } +} + func TestContext2Plan_computedList(t *testing.T) { m := testModule(t, "plan-computed-list") p := testProvider("aws") diff --git a/terraform/test-fixtures/plan-computed-data-resource/main.tf b/terraform/test-fixtures/plan-computed-data-resource/main.tf new file mode 100644 index 000000000..aff26ebde --- /dev/null +++ b/terraform/test-fixtures/plan-computed-data-resource/main.tf @@ -0,0 +1,8 @@ +resource "aws_instance" "foo" { + num = "2" + compute = "foo" +} + +data "aws_vpc" "bar" { + foo = "${aws_instance.foo.foo}" +}