mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 14:07:14 +00:00
Changed test case to use filepath.Walk
This commit is contained in:
parent
67ec00d6b8
commit
439ce51441
@ -558,11 +558,19 @@ func TestCleanSubPaths(t *testing.T) {
|
|||||||
return mounts, nil
|
return mounts, nil
|
||||||
},
|
},
|
||||||
umount: func(mountpath string) error {
|
umount: func(mountpath string) error {
|
||||||
fileInfo, err := ioutil.ReadDir(mountpath)
|
err := filepath.Walk(mountpath, func(path string, info os.FileInfo, err error) error {
|
||||||
for _, file := range fileInfo {
|
if path == mountpath {
|
||||||
if err = os.RemoveAll(filepath.Join(mountpath, file.Name())); err != nil {
|
// Skip top level directory
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = os.RemoveAll(path); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
return filepath.SkipDir
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("error processing %s: %s", mountpath, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user