From f521fcca978e0e297d92c4f63c62382341a33777 Mon Sep 17 00:00:00 2001 From: James Bardin Date: Tue, 1 Dec 2020 09:15:36 -0500 Subject: [PATCH] cleanup error handling and some for loops --- command/e2etest/automation_test.go | 2 +- command/e2etest/primary_test.go | 2 +- command/e2etest/providers_mirror_test.go | 6 +++--- command/e2etest/unmanaged_test.go | 3 +++ 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/command/e2etest/automation_test.go b/command/e2etest/automation_test.go index b7214bc0f..d65afd177 100644 --- a/command/e2etest/automation_test.go +++ b/command/e2etest/automation_test.go @@ -108,7 +108,7 @@ func TestPlanApplyInAutomation(t *testing.T) { stateResources := state.RootModule().Resources var gotResources []string - for n, _ := range stateResources { + for n := range stateResources { gotResources = append(gotResources, n) } sort.Strings(gotResources) diff --git a/command/e2etest/primary_test.go b/command/e2etest/primary_test.go index 28aa3c451..074e4649e 100644 --- a/command/e2etest/primary_test.go +++ b/command/e2etest/primary_test.go @@ -107,7 +107,7 @@ func TestPrimarySeparatePlan(t *testing.T) { stateResources := state.RootModule().Resources var gotResources []string - for n, _ := range stateResources { + for n := range stateResources { gotResources = append(gotResources, n) } sort.Strings(gotResources) diff --git a/command/e2etest/providers_mirror_test.go b/command/e2etest/providers_mirror_test.go index 32512a665..5112fd8eb 100644 --- a/command/e2etest/providers_mirror_test.go +++ b/command/e2etest/providers_mirror_test.go @@ -54,7 +54,7 @@ func TestTerraformProvidersMirror(t *testing.T) { "registry.terraform.io/hashicorp/template/terraform-provider-template_2.1.1_windows_386.zip", } var got []string - err = filepath.Walk(outputDir, func(path string, info os.FileInfo, err error) error { + walkErr := filepath.Walk(outputDir, func(path string, info os.FileInfo, err error) error { if info.IsDir() { return nil // we only care about leaf files for this test } @@ -65,8 +65,8 @@ func TestTerraformProvidersMirror(t *testing.T) { got = append(got, filepath.ToSlash(relPath)) return nil }) - if err != nil { - t.Fatal(err) + if walkErr != nil { + t.Fatal(walkErr) } sort.Strings(got) diff --git a/command/e2etest/unmanaged_test.go b/command/e2etest/unmanaged_test.go index c99760055..b32748ada 100644 --- a/command/e2etest/unmanaged_test.go +++ b/command/e2etest/unmanaged_test.go @@ -140,6 +140,9 @@ func TestUnmanagedSeparatePlan(t *testing.T) { }, }, }) + if err != nil { + t.Fatal(err) + } tf.AddEnv("TF_REATTACH_PROVIDERS=" + string(reattachStr)) tf.AddEnv("PLUGIN_PROTOCOL_VERSION=5")