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

Function TestTestLogger

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

Source from the content-addressed store, hash-verified

35)
36
37func TestTestLogger(t *testing.T) {
38 ts := newTestLogSpy(t)
39 defer ts.AssertPassed()
40
41 log := NewLogger(ts)
42
43 log.Info("received work order")
44 log.Debug("starting work")
45 log.Warn("work may fail")
46 log.Error("work failed", zap.Error(errors.New("great sadness")))
47
48 assert.Panics(t, func() {
49 log.Panic("failed to do work")
50 }, "log.Panic should panic")
51
52 ts.AssertMessages(
53 "INFO received work order",
54 "DEBUG starting work",
55 "WARN work may fail",
56 `ERROR work failed {"error": "great sadness"}`,
57 "PANIC failed to do work",
58 )
59}
60
61func TestTestLoggerSupportsLevels(t *testing.T) {
62 ts := newTestLogSpy(t)

Callers

nothing calls this directly

Calls 10

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

Tested by

no test coverage detected