Skip to content

Commit

Permalink
test: All levels for happy case
Browse files Browse the repository at this point in the history
This tests all log levels for the happy case.
  • Loading branch information
abhinav authored and akshayjshah committed Apr 12, 2018
1 parent 814bd88 commit f65dd74
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions zaptest/logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down

0 comments on commit f65dd74

Please sign in to comment.