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

Function TestLoggerAlwaysFatals

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

Source from the content-addressed store, hash-verified

495}
496
497func TestLoggerAlwaysFatals(t *testing.T) {
498 // Users can disable writing out fatal-level logs, but calls to logger.Fatal()
499 // should still terminate the process.
500 withLogger(t, FatalLevel+1, nil, func(logger *Logger, logs *observer.ObservedLogs) {
501 stub := exit.WithStub(func() { logger.Fatal("") })
502 assert.True(t, stub.Exited, "Expected calls to logger.Fatal to terminate process.")
503
504 stub = exit.WithStub(func() { logger.Log(FatalLevel, "") })
505 assert.True(t, stub.Exited, "Expected calls to logger.Fatal to terminate process.")
506
507 stub = exit.WithStub(func() {
508 if ce := logger.Check(FatalLevel, ""); ce != nil {
509 ce.Write()
510 }
511 })
512 assert.True(t, stub.Exited, "Expected calls to logger.Check(FatalLevel, ...) to terminate process.")
513
514 assert.Equal(t, 0, logs.Len(), "Shouldn't write out logs when fatal-level logging is disabled.")
515 })
516}
517
518func TestLoggerDPanic(t *testing.T) {
519 withLogger(t, DebugLevel, nil, func(logger *Logger, logs *observer.ObservedLogs) {

Callers

nothing calls this directly

Calls 7

WithStubFunction · 0.92
withLoggerFunction · 0.70
CheckMethod · 0.65
WriteMethod · 0.65
FatalMethod · 0.45
LogMethod · 0.45
LenMethod · 0.45

Tested by

no test coverage detected