diff options
author | Felix Lange <fjl@twurst.com> | 2014-10-14 20:33:58 +0800 |
---|---|---|
committer | Felix Lange <fjl@twurst.com> | 2014-10-17 23:20:43 +0800 |
commit | 3b1296077b2f814bf4bf478aea63503d18ece86f (patch) | |
tree | a204331f6b8898c7caeac1f12c35507feda710b2 | |
parent | dac128a029ee8d80d4ebdad64b24506c03d55e63 (diff) | |
download | dexon-3b1296077b2f814bf4bf478aea63503d18ece86f.tar.gz dexon-3b1296077b2f814bf4bf478aea63503d18ece86f.tar.zst dexon-3b1296077b2f814bf4bf478aea63503d18ece86f.zip |
ethlog: Reset before each test
-rw-r--r-- | ethlog/loggers_test.go | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/ethlog/loggers_test.go b/ethlog/loggers_test.go index 2b0d1fb1d..fbfb2c99b 100644 --- a/ethlog/loggers_test.go +++ b/ethlog/loggers_test.go @@ -29,6 +29,8 @@ func (t *TestLogSystem) GetLogLevel() LogLevel { } func TestLoggerFlush(t *testing.T) { + Reset() + logger := NewLogger("TEST") testLogSystem := &TestLogSystem{level: WarnLevel} AddLogSystem(testLogSystem) @@ -36,7 +38,6 @@ func TestLoggerFlush(t *testing.T) { logger.Errorf(".") } Flush() - Reset() output := testLogSystem.Output if output != "[TEST] .[TEST] .[TEST] .[TEST] .[TEST] ." { t.Error("Expected complete logger output '[TEST] .[TEST] .[TEST] .[TEST] .[TEST] .', got ", output) @@ -44,6 +45,8 @@ func TestLoggerFlush(t *testing.T) { } func TestLoggerPrintln(t *testing.T) { + Reset() + logger := NewLogger("TEST") testLogSystem := &TestLogSystem{level: WarnLevel} AddLogSystem(testLogSystem) @@ -52,7 +55,6 @@ func TestLoggerPrintln(t *testing.T) { logger.Infoln("info") logger.Debugln("debug") Flush() - Reset() output := testLogSystem.Output if output != "[TEST] error\n[TEST] warn\n" { t.Error("Expected logger output '[TEST] error\\n[TEST] warn\\n', got ", output) @@ -60,6 +62,8 @@ func TestLoggerPrintln(t *testing.T) { } func TestLoggerPrintf(t *testing.T) { + Reset() + logger := NewLogger("TEST") testLogSystem := &TestLogSystem{level: WarnLevel} AddLogSystem(testLogSystem) @@ -68,7 +72,6 @@ func TestLoggerPrintf(t *testing.T) { logger.Infof("info") logger.Debugf("debug") Flush() - Reset() output := testLogSystem.Output if output != "[TEST] error to { 2}\n[TEST] warn" { t.Error("Expected logger output '[TEST] error to { 2}\\n[TEST] warn', got ", output) @@ -76,6 +79,8 @@ func TestLoggerPrintf(t *testing.T) { } func TestMultipleLogSystems(t *testing.T) { + Reset() + logger := NewLogger("TEST") testLogSystem0 := &TestLogSystem{level: ErrorLevel} testLogSystem1 := &TestLogSystem{level: WarnLevel} @@ -84,7 +89,6 @@ func TestMultipleLogSystems(t *testing.T) { logger.Errorln("error") logger.Warnln("warn") Flush() - Reset() output0 := testLogSystem0.Output output1 := testLogSystem1.Output if output0 != "[TEST] error\n" { @@ -96,6 +100,8 @@ func TestMultipleLogSystems(t *testing.T) { } func TestFileLogSystem(t *testing.T) { + Reset() + logger := NewLogger("TEST") filename := "test.log" file, _ := os.OpenFile(filename, os.O_RDWR|os.O_CREATE, os.ModePerm) @@ -114,6 +120,8 @@ func TestFileLogSystem(t *testing.T) { } func TestNoLogSystem(t *testing.T) { + Reset() + logger := NewLogger("TEST") logger.Warnln("warn") Flush() |