cleanup tempfiles in unit test

Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>
This commit is contained in:
Li Zhijian
2020-06-18 11:24:46 +08:00
parent 15e95e4896
commit 02eaa4f354
10 changed files with 17 additions and 4 deletions

View File

@@ -283,6 +283,7 @@ func TestGetFileType(t *testing.T) {
for idx, tc := range testCase {
path, cleanUpPath, err := tc.setUp()
defer os.RemoveAll(cleanUpPath) // RemoveAll can deal with a empty path ""
if err != nil {
// Locally passed, but upstream CI is not friendly to create such device files
// Leave "Operation not permitted" out, which can be covered in an e2e test
@@ -291,9 +292,6 @@ func TestGetFileType(t *testing.T) {
}
t.Fatalf("[%d-%s] unexpected error : %v", idx, tc.name, err)
}
if len(cleanUpPath) > 0 {
defer os.RemoveAll(cleanUpPath)
}
fileType, err := hu.GetFileType(path)
if err != nil {