Clean files during tests.

This commit is contained in:
Ludovic Fernandez 2019-03-18 09:34:03 +01:00 committed by Traefiker Bot
parent 5d050ae3ac
commit e271378a97
2 changed files with 5 additions and 3 deletions

View file

@ -44,8 +44,9 @@ func TestLogRotation(t *testing.T) {
if err != nil { if err != nil {
t.Fatalf("Error setting up temporary directory: %s", err) 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" rotatedFileName := fileName + ".rotated"
config := &types.AccessLog{FilePath: fileName, Format: CommonFormat} config := &types.AccessLog{FilePath: fileName, Format: CommonFormat}
@ -585,6 +586,7 @@ func captureStdout(t *testing.T) (out *os.File, restoreStdout func()) {
restoreStdout = func() { restoreStdout = func() {
os.Stdout = original os.Stdout = original
os.RemoveAll(file.Name())
} }
return file, restoreStdout return file, restoreStdout

View file

@ -254,7 +254,7 @@ func createProvider(t *testing.T, test ProvideTestCase, watch bool) (*Provider,
} }
return provider, func() { return provider, func() {
os.Remove(tempDir) os.RemoveAll(tempDir)
} }
} }
@ -340,7 +340,7 @@ func createTLS(n int) string {
func TestTLSContent(t *testing.T) { func TestTLSContent(t *testing.T) {
tempDir := createTempDir(t, "testdir") tempDir := createTempDir(t, "testdir")
defer os.Remove(tempDir) defer os.RemoveAll(tempDir)
fileTLS := createRandomFile(t, tempDir, "CONTENT") fileTLS := createRandomFile(t, tempDir, "CONTENT")
fileConfig := createRandomFile(t, tempDir, ` fileConfig := createRandomFile(t, tempDir, `