From b62a9c76b17d0afa2c194529f92cf2b016337246 Mon Sep 17 00:00:00 2001 From: Ryan O'Hara-Reid Date: Wed, 23 Jan 2019 14:13:21 +1100 Subject: [PATCH] Fix bug in Logger test where it creates file but doesn't delete (#236) --- logger/logger_test.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/logger/logger_test.go b/logger/logger_test.go index 79ba0812..25558a7f 100644 --- a/logger/logger_test.go +++ b/logger/logger_test.go @@ -35,7 +35,16 @@ func TestSetupOutputsValidPath(t *testing.T) { if err != nil { t.Fatalf("SetupOutputs failed expected nil got %v", err) } - os.Remove(path.Join(LogPath, Logger.File)) + + err = CloseLogFile() + if err != nil { + t.Fatalf("CloseLogFile failed with %v", err) + } + + err = os.Remove(path.Join(LogPath, Logger.File)) + if err != nil { + t.Fatal("Test Failed - SetupOutputsValidPath() error could not remove test file", err) + } } func TestSetupOutputsInValidPath(t *testing.T) { @@ -48,7 +57,10 @@ func TestSetupOutputsInValidPath(t *testing.T) { t.Fatalf("SetupOutputs failed expected %v got %v", os.ErrNotExist, err) } } - os.Remove(path.Join(LogPath, Logger.File)) + err = os.Remove(path.Join(LogPath, Logger.File)) + if err == nil { + t.Fatal("Test Failed - SetupOutputsInValidPath() error cannot be nil") + } } func BenchmarkDebugf(b *testing.B) {