cleanup: getRootDir function

This commit is contained in:
andyzhangx 2025-03-13 09:21:30 +00:00
parent 5651c852db
commit 0d8402be32
2 changed files with 0 additions and 47 deletions

View File

@ -217,12 +217,6 @@ func waitForPathNotExistWithTimeout(path string, timeout time.Duration) error {
}
}
// getRootDir returns the root directory of the given directory
func getRootDir(path string) string {
parts := strings.Split(path, "/")
return parts[0]
}
// removeEmptyDirs removes empty directories in the given directory dir until the parent directory parentDir
// It will remove all empty directories in the path from the given directory to the parent directory
// It will not remove the parent directory parentDir

View File

@ -388,47 +388,6 @@ func TestWaitForPathNotExistWithTimeout(t *testing.T) {
}
}
func TestGetRootPath(t *testing.T) {
tests := []struct {
desc string
dir string
expected string
}{
{
desc: "empty path",
dir: "",
expected: "",
},
{
desc: "root path",
dir: "/",
expected: "",
},
{
desc: "subdir path",
dir: "/subdir",
expected: "",
},
{
desc: "subdir path without leading slash",
dir: "subdir",
expected: "subdir",
},
{
desc: "multiple subdir path without leading slash",
dir: "subdir/subdir2",
expected: "subdir",
},
}
for _, test := range tests {
result := getRootDir(test.dir)
if result != test.expected {
t.Errorf("Unexpected result: %s, expected: %s", result, test.expected)
}
}
}
func TestRemoveEmptyDirs(t *testing.T) {
parentDir, _ := os.Getwd()
emptyDirOneLevel, _ := getWorkDirPath("emptyDir1")