From f375691819547c3309c9819e2452f10cd4e14eb3 Mon Sep 17 00:00:00 2001 From: James Bardin Date: Mon, 19 Nov 2018 17:59:38 -0500 Subject: [PATCH] add missing key-value from test --- helper/plugin/grpc_provider_test.go | 2 +- states/state_string.go | 7 ++++++- terraform/context_plan_test.go | 3 ++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/helper/plugin/grpc_provider_test.go b/helper/plugin/grpc_provider_test.go index f27edf399..1dcc04df5 100644 --- a/helper/plugin/grpc_provider_test.go +++ b/helper/plugin/grpc_provider_test.go @@ -662,7 +662,7 @@ func TestNormalizeFlatmapContainers(t *testing.T) { expect: map[string]string{"id": "78629a0f5f3f164f"}, }, { - attrs: map[string]string{"set.2.required": "bar", "set.2.list.#": "1", "set.2.list.0": "x", "set.1.list.#": "0"}, + attrs: map[string]string{"set.2.required": "bar", "set.2.list.#": "1", "set.2.list.0": "x", "set.1.list.#": "0", "set.#": "2"}, expect: map[string]string{"set.2.list.#": "1", "set.2.list.0": "x", "set.2.required": "bar", "set.#": "1"}, }, } { diff --git a/states/state_string.go b/states/state_string.go index 8a81a78f1..bca4581c9 100644 --- a/states/state_string.go +++ b/states/state_string.go @@ -164,11 +164,16 @@ func (m *Module) testString() string { } } attrKeys := make([]string, 0, len(attributes)) - for ak, _ := range attributes { + for ak, val := range attributes { if ak == "id" { continue } + // don't show empty containers in the output + if val == "0" && (strings.HasSuffix(ak, ".#") || strings.HasSuffix(ak, ".%")) { + continue + } + attrKeys = append(attrKeys, ak) } diff --git a/terraform/context_plan_test.go b/terraform/context_plan_test.go index 623c93d32..53bd8136c 100644 --- a/terraform/context_plan_test.go +++ b/terraform/context_plan_test.go @@ -2159,7 +2159,8 @@ func TestContext2Plan_computedList(t *testing.T) { switch i := ric.Addr.String(); i { case "aws_instance.bar": checkVals(t, objectVal(t, schema, map[string]cty.Value{ - "foo": cty.UnknownVal(cty.String), + "list": cty.UnknownVal(cty.List(cty.String)), + "foo": cty.UnknownVal(cty.String), }), ric.After) case "aws_instance.foo": checkVals(t, objectVal(t, schema, map[string]cty.Value{