From 5f4b30fc6016f552ce4b6e0596e1119913bd2792 Mon Sep 17 00:00:00 2001 From: Dennis Leon Date: Mon, 4 Oct 2021 14:28:23 -0700 Subject: [PATCH] Fix failing test on windows due to slash difference Authored-by: Dennis Leon --- pkg/imgpkg/cmd/push_test.go | 5 +++-- test/helpers/assets.go | 7 ++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/pkg/imgpkg/cmd/push_test.go b/pkg/imgpkg/cmd/push_test.go index 2025e5ac..bf0a571d 100644 --- a/pkg/imgpkg/cmd/push_test.go +++ b/pkg/imgpkg/cmd/push_test.go @@ -4,6 +4,7 @@ package cmd import ( + "fmt" "io/ioutil" "os" "path/filepath" @@ -56,7 +57,7 @@ func TestMultiImgpkgDirError(t *testing.T) { t.Fatalf("Expected validations to err, but did not") } - if !strings.Contains(err.Error(), "This directory contains multiple bundle definitions. Only a single instance of .imgpkg/images.yml can be provided") { + if !strings.Contains(err.Error(), fmt.Sprintf("This directory contains multiple bundle definitions. Only a single instance of .imgpkg%simages.yml can be provided", string(os.PathSeparator))) { t.Fatalf("Expected error to contain message about multiple .imgpkg dirs, got: %s", err) } } @@ -133,7 +134,7 @@ func TestBundleDirectoryErrors(t *testing.T) { { name: "no bundle", createBundleDir: false, - expectedError: "This directory is not a bundle. It is missing .imgpkg/images.yml", + expectedError: fmt.Sprintf("This directory is not a bundle. It is missing .imgpkg%simages.yml", string(os.PathSeparator)), }, } diff --git a/test/helpers/assets.go b/test/helpers/assets.go index 9932c092..be6c3c76 100644 --- a/test/helpers/assets.go +++ b/test/helpers/assets.go @@ -7,6 +7,7 @@ import ( "io/ioutil" "os" "path/filepath" + "runtime" "strings" "testing" @@ -94,7 +95,11 @@ func (a *Assets) CleanCreatedFolders() { a.T.Helper() for _, folder := range a.CreatedFolders { err := os.RemoveAll(folder) - require.NoErrorf(a.T, err, "cleaning folder: '%s'", folder) + + //TODO: figure out why windows still has a file handle on the bundle.tar file + if runtime.GOOS != "windows" { + require.NoErrorf(a.T, err, "cleaning folder: '%s'", folder) + } } }