diff --git a/python/utils.go b/python/utils.go index 10654edc00..a8408fae2d 100644 --- a/python/utils.go +++ b/python/utils.go @@ -5,7 +5,7 @@ package python import ( "context" "os" - "path" + "path/filepath" "strings" "github.com/databricks/cli/libs/log" @@ -13,8 +13,8 @@ import ( func CleanupWheelFolder(dir string) { // there or not there - we don't care - os.RemoveAll(path.Join(dir, "__pycache__")) - os.RemoveAll(path.Join(dir, "build")) + os.RemoveAll(filepath.Join(dir, "__pycache__")) + os.RemoveAll(filepath.Join(dir, "build")) eggInfo := FindFilesWithSuffixInPath(dir, ".egg-info") if len(eggInfo) == 0 { return @@ -42,7 +42,7 @@ func FindFilesWithSuffixInPath(dir, suffix string) []string { if !strings.HasSuffix(child.Name(), suffix) { continue } - files = append(files, path.Join(dir, child.Name())) + files = append(files, filepath.Join(dir, child.Name())) } return files } diff --git a/python/utils_test.go b/python/utils_test.go new file mode 100644 index 0000000000..1656d1ecb4 --- /dev/null +++ b/python/utils_test.go @@ -0,0 +1,21 @@ +package python + +import ( + "os" + "path/filepath" + "testing" + + "github.com/stretchr/testify/require" +) + +func TestFindFilesWithSuffixInPath(t *testing.T) { + dir, err := os.Getwd() + require.NoError(t, err) + + files := FindFilesWithSuffixInPath(dir, "test.go") + + matches, err := filepath.Glob(filepath.Join(dir, "*test.go")) + require.NoError(t, err) + + require.ElementsMatch(t, files, matches) +}