From d73b2d778fe15cbd0cee7e5ea1bf9077c5106197 Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Thu, 1 Nov 2018 17:32:30 -0700 Subject: [PATCH] core: TestContext2Plan_requiredModuleOutput to use t.Run This allows us to see the results of the tests for all resources even if one of them fails. --- terraform/context_plan_test.go | 48 ++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/terraform/context_plan_test.go b/terraform/context_plan_test.go index 3a9b826be..03dee235e 100644 --- a/terraform/context_plan_test.go +++ b/terraform/context_plan_test.go @@ -5551,30 +5551,32 @@ func TestContext2Plan_requiredModuleOutput(t *testing.T) { } for _, res := range plan.Changes.Resources { - if res.Action != plans.Create { - t.Fatalf("expected resource creation, got %s", res.Action) - } - ric, err := res.Decode(ty) - if err != nil { - t.Fatal(err) - } + t.Run(fmt.Sprintf("%s %s", res.Action, res.Addr), func(t *testing.T) { + if res.Action != plans.Create { + t.Fatalf("expected resource creation, got %s", res.Action) + } + ric, err := res.Decode(ty) + if err != nil { + t.Fatal(err) + } - var expected cty.Value - switch i := ric.Addr.String(); i { - case "test_resource.root": - expected = objectVal(t, schema, map[string]cty.Value{ - "id": cty.UnknownVal(cty.String), - "required": cty.UnknownVal(cty.String), - }) - case "module.mod.test_resource.for_output": - expected = objectVal(t, schema, map[string]cty.Value{ - "id": cty.UnknownVal(cty.String), - "required": cty.StringVal("val"), - }) - default: - t.Fatal("unknown instance:", i) - } + var expected cty.Value + switch i := ric.Addr.String(); i { + case "test_resource.root": + expected = objectVal(t, schema, map[string]cty.Value{ + "id": cty.UnknownVal(cty.String), + "required": cty.UnknownVal(cty.String), + }) + case "module.mod.test_resource.for_output": + expected = objectVal(t, schema, map[string]cty.Value{ + "id": cty.UnknownVal(cty.String), + "required": cty.StringVal("val"), + }) + default: + t.Fatal("unknown instance:", i) + } - checkVals(t, expected, ric.After) + checkVals(t, expected, ric.After) + }) } }