From 7055457cfd3c1281f9f16c15f037b458fc84a3b6 Mon Sep 17 00:00:00 2001 From: zwwhdls Date: Thu, 12 Dec 2019 10:41:53 +0800 Subject: [PATCH] fix the case with current directory Signed-off-by: zwwhdls --- cmd/helm/pull_test.go | 7 +++---- pkg/action/pull.go | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/cmd/helm/pull_test.go b/cmd/helm/pull_test.go index 8d238e791..8fc5d1ed4 100644 --- a/cmd/helm/pull_test.go +++ b/cmd/helm/pull_test.go @@ -21,7 +21,6 @@ import ( "os" "path/filepath" "regexp" - "strings" "testing" "helm.sh/helm/v3/pkg/repo/repotest" @@ -96,14 +95,14 @@ func TestPullCmd(t *testing.T) { args: "test/test1 --untar --untardir test1", existFile: "test1", wantError: true, - wantErrorMsg: "failed to untar", + wantErrorMsg: fmt.Sprintf("failed to untar: a file or directory with the name %s already exists", filepath.Join(srv.Root(), "test1")), }, { name: "Fetch untar when dir with same name existed", args: "test/test2 --untar --untardir test2", existDir: "test2", wantError: true, - wantErrorMsg: "failed to untar", + wantErrorMsg: fmt.Sprintf("failed to untar: a file or directory with the name %s already exists", filepath.Join(srv.Root(), "test2")), }, { name: "Fetch, verify, untar", @@ -163,7 +162,7 @@ func TestPullCmd(t *testing.T) { _, out, err := executeActionCommand(cmd) if err != nil { if tt.wantError { - if tt.wantErrorMsg != "" && strings.Contains(tt.wantErrorMsg, err.Error()) { + if tt.wantErrorMsg != "" && tt.wantErrorMsg == err.Error() { t.Fatalf("%q reported error not equel wantErr, reported: %s, wanted: %s", tt.name, err, tt.wantErrorMsg) } return diff --git a/pkg/action/pull.go b/pkg/action/pull.go index fb8da612f..360786153 100644 --- a/pkg/action/pull.go +++ b/pkg/action/pull.go @@ -114,7 +114,7 @@ func (p *Pull) Run(chartRef string) (string, error) { return out.String(), errors.Wrap(err, "failed to untar (mkdir)") } - } else { + } else if ud != "." { return out.String(), errors.Errorf("failed to untar: a file or directory with the name %s already exists", ud) }