From 0d8402be32b9fb9dd31ac947066022189a154a3a Mon Sep 17 00:00:00 2001 From: andyzhangx Date: Thu, 13 Mar 2025 09:21:30 +0000 Subject: [PATCH] cleanup: getRootDir function --- pkg/nfs/utils.go | 6 ------ pkg/nfs/utils_test.go | 41 ----------------------------------------- 2 files changed, 47 deletions(-) diff --git a/pkg/nfs/utils.go b/pkg/nfs/utils.go index 1f04d682..53737cb2 100644 --- a/pkg/nfs/utils.go +++ b/pkg/nfs/utils.go @@ -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 diff --git a/pkg/nfs/utils_test.go b/pkg/nfs/utils_test.go index 84a078d3..58a457ff 100644 --- a/pkg/nfs/utils_test.go +++ b/pkg/nfs/utils_test.go @@ -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")