fix the case with current directory

Signed-off-by: zwwhdls <zwwhdls@hotmail.com>
pull/7187/head
zwwhdls 6 years ago
parent b6a174d4bc
commit 7055457cfd

@ -21,7 +21,6 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"regexp" "regexp"
"strings"
"testing" "testing"
"helm.sh/helm/v3/pkg/repo/repotest" "helm.sh/helm/v3/pkg/repo/repotest"
@ -96,14 +95,14 @@ func TestPullCmd(t *testing.T) {
args: "test/test1 --untar --untardir test1", args: "test/test1 --untar --untardir test1",
existFile: "test1", existFile: "test1",
wantError: true, 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", name: "Fetch untar when dir with same name existed",
args: "test/test2 --untar --untardir test2", args: "test/test2 --untar --untardir test2",
existDir: "test2", existDir: "test2",
wantError: true, 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", name: "Fetch, verify, untar",
@ -163,7 +162,7 @@ func TestPullCmd(t *testing.T) {
_, out, err := executeActionCommand(cmd) _, out, err := executeActionCommand(cmd)
if err != nil { if err != nil {
if tt.wantError { 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) t.Fatalf("%q reported error not equel wantErr, reported: %s, wanted: %s", tt.name, err, tt.wantErrorMsg)
} }
return return

@ -114,7 +114,7 @@ func (p *Pull) Run(chartRef string) (string, error) {
return out.String(), errors.Wrap(err, "failed to untar (mkdir)") 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) return out.String(), errors.Errorf("failed to untar: a file or directory with the name %s already exists", ud)
} }

Loading…
Cancel
Save