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

Function TestSugarAddCaller

sugar_test.go:513–536  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

511}
512
513func TestSugarAddCaller(t *testing.T) {
514 tests := []struct {
515 options []Option
516 pat string
517 }{
518 {opts(AddCaller()), `.+/sugar_test.go:[\d]+$`},
519 {opts(AddCaller(), AddCallerSkip(1), AddCallerSkip(-1)), `.+/sugar_test.go:[\d]+$`},
520 {opts(AddCaller(), AddCallerSkip(1)), `.+/common_test.go:[\d]+$`},
521 {opts(AddCaller(), AddCallerSkip(1), AddCallerSkip(5)), `.+/src/runtime/.*:[\d]+$`},
522 }
523 for _, tt := range tests {
524 withSugar(t, DebugLevel, tt.options, func(logger *SugaredLogger, logs *observer.ObservedLogs) {
525 logger.Info("")
526 output := logs.AllUntimed()
527 assert.Equal(t, 1, len(output), "Unexpected number of logs written out.")
528 assert.Regexp(
529 t,
530 tt.pat,
531 output[0].Caller,
532 "Expected to find package name and file name in output.",
533 )
534 })
535 }
536}
537
538func TestSugarAddCallerFail(t *testing.T) {
539 errBuf := &ztest.Buffer{}

Callers

nothing calls this directly

Calls 6

optsFunction · 0.85
AddCallerFunction · 0.85
AddCallerSkipFunction · 0.85
withSugarFunction · 0.85
AllUntimedMethod · 0.80
InfoMethod · 0.45

Tested by

no test coverage detected