From 439ce51441f0429c0b7853aa35fc4503954cb712 Mon Sep 17 00:00:00 2001 From: Janario Oliveira Date: Tue, 17 Sep 2019 07:24:50 +0200 Subject: [PATCH] Changed test case to use `filepath.Walk` --- pkg/volume/util/subpath/subpath_linux_test.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/pkg/volume/util/subpath/subpath_linux_test.go b/pkg/volume/util/subpath/subpath_linux_test.go index f950ed8f821..8a730a090bf 100644 --- a/pkg/volume/util/subpath/subpath_linux_test.go +++ b/pkg/volume/util/subpath/subpath_linux_test.go @@ -558,11 +558,19 @@ func TestCleanSubPaths(t *testing.T) { return mounts, nil }, umount: func(mountpath string) error { - fileInfo, err := ioutil.ReadDir(mountpath) - for _, file := range fileInfo { - if err = os.RemoveAll(filepath.Join(mountpath, file.Name())); err != nil { + err := filepath.Walk(mountpath, func(path string, info os.FileInfo, err error) error { + if path == mountpath { + // Skip top level directory + return nil + } + + if err = os.RemoveAll(path); err != nil { return err } + return filepath.SkipDir + }) + if err != nil { + return fmt.Errorf("error processing %s: %s", mountpath, err) } return nil