From 3f4b7f847db9c99af29d5236653fb62068017a9b Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Thu, 24 May 2018 12:40:33 -0700 Subject: [PATCH] core: Fix TestContext2Plan_ignoreChangesWithFlatmaps Prior to our v0.12 changes this test was confusingly using an attribute named "set", but assigning a map to it. The expected test result suggested that it was actually expecting legacy HCL2's weird interpretation of a single map as a list of maps, and so to retain the intent of the test here (in spite of the contrary name) we type "set" as list of map of string, update the fixture to _actually_ be a list of maps, and then we get the expected test result. --- terraform/context_plan_test.go | 9 +++++++-- .../plan-ignore-changes-with-flatmaps/main.tf | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/terraform/context_plan_test.go b/terraform/context_plan_test.go index c09e514544..dbdd32a3d7 100644 --- a/terraform/context_plan_test.go +++ b/terraform/context_plan_test.go @@ -3821,8 +3821,13 @@ func TestContext2Plan_ignoreChangesWithFlatmaps(t *testing.T) { Attributes: map[string]*configschema.Attribute{ "user_data": {Type: cty.String, Optional: true}, "require_new": {Type: cty.String, Optional: true}, - "set": {Type: cty.Map(cty.String), Optional: true}, - "lst": {Type: cty.List(cty.String), Optional: true}, + + // This test predates the 0.12 work to integrate cty and + // HCL, and so it was ported as-is where its expected + // test output was clearly expecting a list of maps here + // even though it is named "set". + "set": {Type: cty.List(cty.Map(cty.String)), Optional: true}, + "lst": {Type: cty.List(cty.String), Optional: true}, }, }, }, diff --git a/terraform/test-fixtures/plan-ignore-changes-with-flatmaps/main.tf b/terraform/test-fixtures/plan-ignore-changes-with-flatmaps/main.tf index 5d3bc090c1..f61a3d42fc 100644 --- a/terraform/test-fixtures/plan-ignore-changes-with-flatmaps/main.tf +++ b/terraform/test-fixtures/plan-ignore-changes-with-flatmaps/main.tf @@ -2,10 +2,10 @@ resource "aws_instance" "foo" { user_data = "x" require_new = "yes" - set = { + set = [{ a = "1" b = "2" - } + }] lst = ["j", "k"]