From 74ef93abdeaa6565e52240e02d6f7e9013e439e8 Mon Sep 17 00:00:00 2001 From: Alex Bramley Date: Thu, 27 Oct 2011 17:48:15 +0100 Subject: [PATCH] Fix behaviour of CheckWrittenAtLevel() slightly: 1) Adjust alignments for exp/got correctly. 2) Print expected string when nothing logged at level. 3) Check to ensure no unexpected logging occurred at other levels when nothing logged at expected level. --- logging/mock.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/logging/mock.go b/logging/mock.go index fe1a42d..e5456d7 100644 --- a/logging/mock.go +++ b/logging/mock.go @@ -61,7 +61,9 @@ func (m writerMap) CheckWrittenAtLevel(t *testing.T, lv LogLevel, exp string) { // 2011/10/22 10:22:57 log_test.go:: if len(w.written) <= 33 { t.Errorf("Not enough bytes logged at level %s:", LogString(lv)) - t.Errorf("\tgot: %s", string(w.written)) + t.Errorf("exp: %s\n\tgot: %s", exp, string(w.written)) + // Check nothing was written to a different log level here, too. + m.CheckNothingWritten(t) return } s := string(w.written[32:]) @@ -73,7 +75,7 @@ func (m writerMap) CheckWrittenAtLevel(t *testing.T, lv LogLevel, exp string) { exp = LogString(lv) + " " + exp if s != exp { t.Errorf("Log message at level %s differed.", LogString(lv)) - t.Errorf("\texp: %s\n\tgot: %s", exp, s) + t.Errorf("exp: %s\n\tgot: %s", exp, s) } w.reset() // Calling checkNothingWritten here both tests that w.reset() works