mirror of
https://github.com/GoogleContainerTools/kaniko
synced 2026-10-07 22:23:33 +02:00
Fix sorting of parent directories.
This refactoring reversed the order of the "ParentDirectories" function: https://github.com/GoogleContainerTools/kaniko/pull/1155/commits/ffc372a63bca75e5b7c680c981d2444fc4017897#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:
+2
-2
@@ -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)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user