From 84a07a47746e6f64b83e707b940e2babede836b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Cuadrado=20Juan?= Date: Mon, 26 Jul 2021 16:53:18 +0200 Subject: [PATCH] test: Make internal/resolver/resolver_test.go pass on Win MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TestGetLocalPath() needs Windows-specific expected strings. Signed-off-by: VĂ­ctor Cuadrado Juan --- internal/resolver/resolver_test.go | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/internal/resolver/resolver_test.go b/internal/resolver/resolver_test.go index bc84ba952..419f8f316 100644 --- a/internal/resolver/resolver_test.go +++ b/internal/resolver/resolver_test.go @@ -16,6 +16,7 @@ limitations under the License. package resolver import ( + "runtime" "testing" "helm.sh/helm/v3/pkg/chart" @@ -246,24 +247,28 @@ func TestGetLocalPath(t *testing.T) { repo string chartpath string expect string + winExpect string err bool }{ { - name: "absolute path", - repo: "file:////tmp", - expect: "/tmp", + name: "absolute path", + repo: "file:////", + expect: "/", + winExpect: "\\", }, { name: "relative path", repo: "file://../../testdata/chartpath/base", chartpath: "foo/bar", expect: "testdata/chartpath/base", + winExpect: "testdata\\chartpath\\base", }, { name: "current directory path", repo: "../charts/localdependency", chartpath: "testdata/chartpath/charts", expect: "testdata/chartpath/charts/localdependency", + winExpect: "testdata\\chartpath\\charts\\localdependency", }, { name: "invalid local path", @@ -291,8 +296,12 @@ func TestGetLocalPath(t *testing.T) { if tt.err { t.Fatalf("Expected error in test %q", tt.name) } - if p != tt.expect { - t.Errorf("%q: expected %q, got %q", tt.name, tt.expect, p) + expect := tt.expect + if runtime.GOOS == "windows" { + expect = tt.winExpect + } + if p != expect { + t.Errorf("%q: expected %q, got %q", tt.name, expect, p) } }) }