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

Function TestTestLoggerSupportsWrappedZapOptions

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

Source from the content-addressed store, hash-verified

81}
82
83func TestTestLoggerSupportsWrappedZapOptions(t *testing.T) {
84 ts := newTestLogSpy(t)
85 defer ts.AssertPassed()
86
87 log := NewLogger(ts, WrapOptions(zap.AddCaller(), zap.Fields(zap.String("k1", "v1"))))
88
89 log.Info("received work order")
90 log.Debug("starting work")
91 log.Warn("work may fail")
92 log.Error("work failed", zap.Error(errors.New("great sadness")))
93
94 assert.Panics(t, func() {
95 log.Panic("failed to do work")
96 }, "log.Panic should panic")
97
98 ts.AssertMessages(
99 `INFO zaptest/logger_test.go:89 received work order {"k1": "v1"}`,
100 `DEBUG zaptest/logger_test.go:90 starting work {"k1": "v1"}`,
101 `WARN zaptest/logger_test.go:91 work may fail {"k1": "v1"}`,
102 `ERROR zaptest/logger_test.go:92 work failed {"k1": "v1", "error": "great sadness"}`,
103 `PANIC zaptest/logger_test.go:95 failed to do work {"k1": "v1"}`,
104 )
105}
106
107func TestTestingWriter(t *testing.T) {
108 ts := newTestLogSpy(t)

Callers

nothing calls this directly

Calls 14

InfoMethod · 0.95
DebugMethod · 0.95
WarnMethod · 0.95
ErrorMethod · 0.95
PanicMethod · 0.95
AddCallerFunction · 0.92
FieldsFunction · 0.92
StringFunction · 0.92
ErrorFunction · 0.92
newTestLogSpyFunction · 0.85
WrapOptionsFunction · 0.85
AssertPassedMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…