From f65dd746ae581ee97ac632581c15429c37aa8919 Mon Sep 17 00:00:00 2001 From: Abhinav Gupta Date: Mon, 26 Mar 2018 14:58:40 -0700 Subject: [PATCH] test: All levels for happy case This tests all log levels for the happy case. --- zaptest/logger_test.go | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/zaptest/logger_test.go b/zaptest/logger_test.go index 13acd8714..efa57e2da 100644 --- a/zaptest/logger_test.go +++ b/zaptest/logger_test.go @@ -32,19 +32,29 @@ import ( "github.com/stretchr/testify/assert" ) -func TestTestLoggerIncludesDebug(t *testing.T) { +func TestTestLogger(t *testing.T) { ts := newTestLogSpy(t) log := NewLogger(ts) - log.Debug("calculating") - log.Info("finished calculating", zap.Int("answer", 42)) + + log.Info("received work order") + log.Debug("starting work") + log.Warn("work may fail") + log.Error("work failed", zap.Error(errors.New("great sadness"))) + + assert.Panics(t, func() { + log.Panic("failed to do work") + }, "log.Panic should panic") ts.AssertMessages( - "DEBUG calculating", - `INFO finished calculating {"answer": 42}`, + "INFO received work order", + "DEBUG starting work", + "WARN work may fail", + `ERROR work failed {"error": "great sadness"}`, + "PANIC failed to do work", ) } -func TestTestLoggerAt(t *testing.T) { +func TestTestLoggerSupportsLevels(t *testing.T) { ts := newTestLogSpy(t) log := NewLogger(ts, Level(zap.WarnLevel))