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

Function TestLoggerAlwaysPanics

logger_test.go:481–495  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

479}
480
481func TestLoggerAlwaysPanics(t *testing.T) {
482 // Users can disable writing out panic-level logs, but calls to logger.Panic()
483 // should still call panic().
484 withLogger(t, FatalLevel, nil, func(logger *Logger, logs *observer.ObservedLogs) {
485 msg := "Even if output is disabled, logger.Panic should always panic."
486 assert.Panics(t, func() { logger.Panic("foo") }, msg)
487 assert.Panics(t, func() { logger.Log(PanicLevel, "foo") }, msg)
488 assert.Panics(t, func() {
489 if ce := logger.Check(PanicLevel, "foo"); ce != nil {
490 ce.Write()
491 }
492 }, msg)
493 assert.Equal(t, 0, logs.Len(), "Panics shouldn't be written out if PanicLevel is disabled.")
494 })
495}
496
497func TestLoggerAlwaysFatals(t *testing.T) {
498 // Users can disable writing out fatal-level logs, but calls to logger.Fatal()

Callers

nothing calls this directly

Calls 6

withLoggerFunction · 0.70
CheckMethod · 0.65
WriteMethod · 0.65
PanicMethod · 0.45
LogMethod · 0.45
LenMethod · 0.45

Tested by

no test coverage detected