Fix sorting of parent directories.
This refactoring reversed the order of the "ParentDirectories" function: ffc372a63b (diff-d36eb675aa49a7b471e3a2be77005b18R465)
As a side-effect, parent directories weren't added in lexicographical
order, which broke some tests. We now ensure in unit test that the order
of the ParentDirectories function is stable.
This commit is contained in:
parent
fd8a2d6dd8
commit
14170aa455
|
|
@ -468,10 +468,10 @@ func ParentDirectories(path string) []string {
|
|||
}
|
||||
dir, _ = filepath.Split(dir)
|
||||
dir = filepath.Clean(dir)
|
||||
paths = append(paths, dir)
|
||||
paths = append([]string{dir}, paths...)
|
||||
}
|
||||
if len(paths) == 0 {
|
||||
paths = append(paths, config.RootDir)
|
||||
paths = []string{config.RootDir}
|
||||
}
|
||||
return paths
|
||||
}
|
||||
|
|
|
|||
|
|
@ -213,8 +213,6 @@ func Test_ParentDirectories(t *testing.T) {
|
|||
defer func() { config.RootDir = original }()
|
||||
config.RootDir = tt.rootDir
|
||||
actual := ParentDirectories(tt.path)
|
||||
sort.Strings(actual)
|
||||
sort.Strings(tt.expected)
|
||||
|
||||
testutil.CheckErrorAndDeepEqual(t, false, nil, tt.expected, actual)
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in New Issue