Fix bug in snapshotting
This commit is contained in:
parent
4f4dda0563
commit
54282e3e8c
|
|
@ -149,7 +149,7 @@ func TestSnapshotFiles(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
expectedFiles := []string{"/tmp", filepath.Join(testDir, "foo")}
|
expectedFiles := []string{"/", "/tmp", filepath.Join(testDir, "foo")}
|
||||||
|
|
||||||
// Check contents of the snapshot, make sure contents is equivalent to snapshotFiles
|
// Check contents of the snapshot, make sure contents is equivalent to snapshotFiles
|
||||||
reader := bytes.NewReader(contents)
|
reader := bytes.NewReader(contents)
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ func ResolveEnvironmentReplacement(value string, envs []string, isFilepath bool)
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
fp = filepath.Clean(fp)
|
fp = filepath.Clean(fp)
|
||||||
if IsDestDir(value) {
|
if IsDestDir(value) && !IsDestDir(fp) {
|
||||||
fp = fp + "/"
|
fp = fp + "/"
|
||||||
}
|
}
|
||||||
return fp, nil
|
return fp, nil
|
||||||
|
|
|
||||||
|
|
@ -336,12 +336,12 @@ func Files(root string) ([]string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ParentDirectories returns a list of paths to all parent directories
|
// ParentDirectories returns a list of paths to all parent directories
|
||||||
// Ex. /some/temp/dir -> [/some, /some/temp, /some/temp/dir]
|
// Ex. /some/temp/dir -> [/, /some, /some/temp, /some/temp/dir]
|
||||||
func ParentDirectories(path string) []string {
|
func ParentDirectories(path string) []string {
|
||||||
path = filepath.Clean(path)
|
path = filepath.Clean(path)
|
||||||
dirs := strings.Split(path, "/")
|
dirs := strings.Split(path, "/")
|
||||||
dirPath := constants.RootDir
|
dirPath := constants.RootDir
|
||||||
var paths []string
|
paths := []string{constants.RootDir}
|
||||||
for index, dir := range dirs {
|
for index, dir := range dirs {
|
||||||
if dir == "" || index == (len(dirs)-1) {
|
if dir == "" || index == (len(dirs)-1) {
|
||||||
continue
|
continue
|
||||||
|
|
|
||||||
|
|
@ -142,6 +142,7 @@ func Test_ParentDirectories(t *testing.T) {
|
||||||
name: "regular path",
|
name: "regular path",
|
||||||
path: "/path/to/dir",
|
path: "/path/to/dir",
|
||||||
expected: []string{
|
expected: []string{
|
||||||
|
"/",
|
||||||
"/path",
|
"/path",
|
||||||
"/path/to",
|
"/path/to",
|
||||||
},
|
},
|
||||||
|
|
@ -149,7 +150,9 @@ func Test_ParentDirectories(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "current directory",
|
name: "current directory",
|
||||||
path: ".",
|
path: ".",
|
||||||
expected: nil,
|
expected: []string{
|
||||||
|
"/",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue