diff --git a/pkg/metricscollector/v1beta1/file-metricscollector/file-metricscollector_test.go b/pkg/metricscollector/v1beta1/file-metricscollector/file-metricscollector_test.go index 0a0fa09bc9d..6c634b5d87f 100644 --- a/pkg/metricscollector/v1beta1/file-metricscollector/file-metricscollector_test.go +++ b/pkg/metricscollector/v1beta1/file-metricscollector/file-metricscollector_test.go @@ -42,7 +42,8 @@ const ( ) var ( - testJsonDataPath = filepath.Join("testdata", "JSON") + testDir = "testdata" + testJsonDataPath = filepath.Join(testDir, "JSON") testTextDataPath = filepath.Join("testdata", "TEXT") ) @@ -56,7 +57,7 @@ func TestCollectObservationLog(t *testing.T) { if err := generateTEXTTestFiles(); err != nil { t.Fatal(err) } - defer deleteTestDirs() + defer os.RemoveAll(testDir) testCases := map[string]struct { filePath string @@ -337,18 +338,6 @@ func generateTestDirs() error { return nil } -func deleteTestDirs() error { - if err := os.RemoveAll(filepath.Dir(testJsonDataPath)); err != nil { - return err - } - - if err := os.RemoveAll(filepath.Dir(testTextDataPath)); err != nil { - return err - } - - return nil -} - func generateJSONTestFiles() error { testData := []struct { fileName string