From e271378a97b915bc9425ec7741b56cbb68a0cd93 Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Mon, 18 Mar 2019 09:34:03 +0100 Subject: [PATCH] Clean files during tests. --- pkg/middlewares/accesslog/logger_test.go | 4 +++- pkg/provider/file/file_test.go | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/middlewares/accesslog/logger_test.go b/pkg/middlewares/accesslog/logger_test.go index 228599c72..62d6cef73 100644 --- a/pkg/middlewares/accesslog/logger_test.go +++ b/pkg/middlewares/accesslog/logger_test.go @@ -44,8 +44,9 @@ func TestLogRotation(t *testing.T) { if err != nil { t.Fatalf("Error setting up temporary directory: %s", err) } + defer os.RemoveAll(tempDir) - fileName := tempDir + "traefik.log" + fileName := filepath.Join(tempDir, "traefik.log") rotatedFileName := fileName + ".rotated" config := &types.AccessLog{FilePath: fileName, Format: CommonFormat} @@ -585,6 +586,7 @@ func captureStdout(t *testing.T) (out *os.File, restoreStdout func()) { restoreStdout = func() { os.Stdout = original + os.RemoveAll(file.Name()) } return file, restoreStdout diff --git a/pkg/provider/file/file_test.go b/pkg/provider/file/file_test.go index 326448035..2c1b90b8a 100644 --- a/pkg/provider/file/file_test.go +++ b/pkg/provider/file/file_test.go @@ -254,7 +254,7 @@ func createProvider(t *testing.T, test ProvideTestCase, watch bool) (*Provider, } return provider, func() { - os.Remove(tempDir) + os.RemoveAll(tempDir) } } @@ -340,7 +340,7 @@ func createTLS(n int) string { func TestTLSContent(t *testing.T) { tempDir := createTempDir(t, "testdir") - defer os.Remove(tempDir) + defer os.RemoveAll(tempDir) fileTLS := createRandomFile(t, tempDir, "CONTENT") fileConfig := createRandomFile(t, tempDir, `