From 05bf08b2ec2df1176a8d928b5259ca9bf2c5e965 Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Fri, 25 May 2018 19:46:28 -0700 Subject: [PATCH] core: Remove context apply test for map variable merging We no longer have this merge behavior, because it is inconsistent with how variables behave in all other contexts and similar behavior can now be achieved by merging the user's input with a predefined map in a local value expression. --- terraform/context_apply_test.go | 49 ------------------- .../apply-map-var-override/main.tf | 14 ------ 2 files changed, 63 deletions(-) delete mode 100644 terraform/test-fixtures/apply-map-var-override/main.tf diff --git a/terraform/context_apply_test.go b/terraform/context_apply_test.go index 48289957ad..6f6d02b36d 100644 --- a/terraform/context_apply_test.go +++ b/terraform/context_apply_test.go @@ -2432,55 +2432,6 @@ func TestContext2Apply_provisionerInterpCount(t *testing.T) { } } -func TestContext2Apply_mapVariableOverride(t *testing.T) { - m := testModule(t, "apply-map-var-override") - p := testProvider("aws") - p.ApplyFn = testApplyFn - p.DiffFn = testDiffFn - ctx := testContext2(t, &ContextOpts{ - Config: m, - ProviderResolver: ResourceProviderResolverFixed( - map[string]ResourceProviderFactory{ - "aws": testProviderFuncFixed(p), - }, - ), - Variables: InputValues{ - "images": &InputValue{ - Value: cty.MapVal(map[string]cty.Value{ - "us-west-2": cty.StringVal("overridden"), - }), - SourceType: ValueFromCaller, - }, - }, - }) - - if _, diags := ctx.Plan(); diags.HasErrors() { - t.Fatalf("diags: %s", diags.Err()) - } - - state, diags := ctx.Apply() - if diags.HasErrors() { - t.Fatalf("diags: %s", diags.Err()) - } - - actual := strings.TrimSpace(state.String()) - expected := strings.TrimSpace(` -aws_instance.bar: - ID = foo - provider = provider.aws - ami = overridden - type = aws_instance -aws_instance.foo: - ID = foo - provider = provider.aws - ami = image-1234 - type = aws_instance - `) - if actual != expected { - t.Fatalf("got: \n%s\nexpected: \n%s", actual, expected) - } -} - func TestContext2Apply_moduleBasic(t *testing.T) { m := testModule(t, "apply-module") p := testProvider("aws") diff --git a/terraform/test-fixtures/apply-map-var-override/main.tf b/terraform/test-fixtures/apply-map-var-override/main.tf deleted file mode 100644 index bd0fadcaa0..0000000000 --- a/terraform/test-fixtures/apply-map-var-override/main.tf +++ /dev/null @@ -1,14 +0,0 @@ -variable "images" { - default = { - us-east-1 = "image-1234" - us-west-2 = "image-4567" - } -} - -resource "aws_instance" "foo" { - ami = "${lookup(var.images, "us-east-1")}" -} - -resource "aws_instance" "bar" { - ami = "${lookup(var.images, "us-west-2")}" -}