From 54de9057ba2b6cfecab462dcff6e83ebe383118d Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 19 Jan 2016 12:37:55 -0800 Subject: [PATCH] terraform: failing test case --- terraform/context_plan_test.go | 23 +++++++++++++++++++ terraform/terraform_test.go | 12 ++++++++++ .../test-fixtures/plan-escaped-var/main.tf | 3 +++ 3 files changed, 38 insertions(+) create mode 100644 terraform/test-fixtures/plan-escaped-var/main.tf diff --git a/terraform/context_plan_test.go b/terraform/context_plan_test.go index e91fc7747..7963bdb7f 100644 --- a/terraform/context_plan_test.go +++ b/terraform/context_plan_test.go @@ -104,6 +104,29 @@ func TestContext2Plan_emptyDiff(t *testing.T) { } } +func TestContext2Plan_escapedVar(t *testing.T) { + m := testModule(t, "plan-escaped-var") + 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) + } + + actual := strings.TrimSpace(plan.String()) + expected := strings.TrimSpace(testTerraformPlanEscapedVarStr) + if actual != expected { + t.Fatalf("bad:\n%s", actual) + } +} + func TestContext2Plan_minimal(t *testing.T) { m := testModule(t, "plan-empty") p := testProvider("aws") diff --git a/terraform/terraform_test.go b/terraform/terraform_test.go index 3b1653f43..0fc0b71fe 100644 --- a/terraform/terraform_test.go +++ b/terraform/terraform_test.go @@ -983,6 +983,18 @@ STATE: ` +const testTerraformPlanEscapedVarStr = ` +DIFF: + +CREATE: aws_instance.foo + foo: "" => "bar-${baz}" + type: "" => "aws_instance" + +STATE: + + +` + const testTerraformPlanModulesStr = ` DIFF: diff --git a/terraform/test-fixtures/plan-escaped-var/main.tf b/terraform/test-fixtures/plan-escaped-var/main.tf new file mode 100644 index 000000000..5a017207c --- /dev/null +++ b/terraform/test-fixtures/plan-escaped-var/main.tf @@ -0,0 +1,3 @@ +resource "aws_instance" "foo" { + foo = "bar-$${baz}" +}