From 2987d253355752ccb3c12d9dad1ad13fcb9f4e7c Mon Sep 17 00:00:00 2001 From: Adrien Delorme Date: Mon, 2 Nov 2020 17:52:19 +0100 Subject: [PATCH] simplify tests --- hcl2template/common_test.go | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/hcl2template/common_test.go b/hcl2template/common_test.go index a5c8b90bd..08f4ea10b 100644 --- a/hcl2template/common_test.go +++ b/hcl2template/common_test.go @@ -74,26 +74,12 @@ func testParse(t *testing.T, tests []parseTest) { } if gotCfg != nil && !tt.parseWantDiagHasErrors { - gotInputVar := gotCfg.InputVariables - for name, value := range tt.parseWantCfg.InputVariables { - if variable, ok := gotInputVar[name]; ok { - if diff := cmp.Diff(variable, value, cmpOpts...); diff != "" { - t.Fatalf("Parser.parse(): unexpected variable values %s: %s", name, diff) - } - } else { - t.Fatalf("Parser.parse() missing input variable. %s", name) - } + if diff := cmp.Diff(tt.parseWantCfg.InputVariables, gotCfg.InputVariables, cmpOpts...); diff != "" { + t.Fatalf("Parser.parse() unexpected input vars. %s", diff) } - gotLocalVar := gotCfg.LocalVariables - for name, value := range tt.parseWantCfg.LocalVariables { - if variable, ok := gotLocalVar[name]; ok { - if diff := cmp.Diff(variable, value, cmpOpts...); diff != "" { - t.Fatalf("Parser.parse(): unexpected variable values %s: %s", name, diff) - } - } else { - t.Fatalf("Parser.parse() missing local variable. %s", name) - } + if diff := cmp.Diff(tt.parseWantCfg.LocalVariables, gotCfg.LocalVariables, cmpOpts...); diff != "" { + t.Fatalf("Parser.parse() unexpected local vars. %s", diff) } }