From 3dc30db64cfdebff1e884a1e3d3c08c3ff5eb83c Mon Sep 17 00:00:00 2001 From: mitch Date: Wed, 27 Apr 2022 19:20:10 -0400 Subject: [PATCH] Fixed tests --- cmd/main.go | 4 ++-- configManagement_test.go | 11 +++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index 679822b..90f5912 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -43,13 +43,13 @@ func main() { versionsFromConfig, err = versionedTerraform.LoadVersionsFromConfig(configDir, configFileLocation) if err != nil { - fmt.Printf("Unable to read config: %v", err) + fmt.Printf("Unable to read config: %v\n", err) os.Exit(1) } needsUpdate, err := versionedTerraform.NeedToUpdateAvailableVersions(configDir, configFileLocation) if os.ErrNotExist == err { - fmt.Println("Unable to update version: %v", err) + fmt.Printf("Unable to update version: %v\n", err) } if needsUpdate { diff --git a/configManagement_test.go b/configManagement_test.go index a9dbc28..ba1eaf1 100644 --- a/configManagement_test.go +++ b/configManagement_test.go @@ -23,26 +23,26 @@ func TestUpdateAvailableVersions(t *testing.T) { } t.Run("Test success last update time", func(t *testing.T) { - want := true + want := false got, err := NeedToUpdateAvailableVersions(fs, "successConfig.conf") if err != nil { t.Fatal(err) } if got != want { - t.Errorf("updateAvailableVersions had incorrect output expected %v got %v", got, want) + t.Errorf("updateAvailableVersions had incorrect output expected %v got %v", want, got) } }) t.Run("Test failed last update time", func(t *testing.T) { - want := false + want := true got, err := NeedToUpdateAvailableVersions(fs, "failConfig.conf") if err != nil { t.Fatal(err) } if got != want { - t.Errorf("updateAvailableVersions had incorrect output expected %v got %v", got, want) + t.Errorf("updateAvailableVersions had incorrect output expected %v got %v", want, got) } }) } @@ -96,6 +96,9 @@ func TestInstalledVersions(t *testing.T) { "terraform_1.1.9": {Data: []byte("")}, "terraform_1.1.10": {Data: []byte("")}, "terraform_1.1.11": {Data: []byte("")}, + "terraform_0.14.0": {Data: []byte("")}, + "terraform_0.13.1": {Data: []byte("")}, + "terraform_0.13.0": {Data: []byte("")}, } t.Run("Test installed versions", func(t *testing.T) {