MCPcopy
hub / github.com/uber-go/zap / TestTestLoggerSupportsLevels

Function TestTestLoggerSupportsLevels

zaptest/logger_test.go:61–81  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

59}
60
61func TestTestLoggerSupportsLevels(t *testing.T) {
62 ts := newTestLogSpy(t)
63 defer ts.AssertPassed()
64
65 log := NewLogger(ts, Level(zap.WarnLevel))
66
67 log.Info("received work order")
68 log.Debug("starting work")
69 log.Warn("work may fail")
70 log.Error("work failed", zap.Error(errors.New("great sadness")))
71
72 assert.Panics(t, func() {
73 log.Panic("failed to do work")
74 }, "log.Panic should panic")
75
76 ts.AssertMessages(
77 "WARN work may fail",
78 `ERROR work failed {"error": "great sadness"}`,
79 "PANIC failed to do work",
80 )
81}
82
83func TestTestLoggerSupportsWrappedZapOptions(t *testing.T) {
84 ts := newTestLogSpy(t)

Callers

nothing calls this directly

Calls 11

InfoMethod · 0.95
DebugMethod · 0.95
WarnMethod · 0.95
ErrorMethod · 0.95
PanicMethod · 0.95
ErrorFunction · 0.92
newTestLogSpyFunction · 0.85
AssertPassedMethod · 0.80
AssertMessagesMethod · 0.80
NewLoggerFunction · 0.70
LevelFunction · 0.70

Tested by

no test coverage detected