(t *testing.T)
| 588 | } |
| 589 | |
| 590 | func TestLoggerWriteFailure(t *testing.T) { |
| 591 | errSink := &ztest.Buffer{} |
| 592 | logger := New( |
| 593 | zapcore.NewCore( |
| 594 | zapcore.NewJSONEncoder(NewProductionConfig().EncoderConfig), |
| 595 | zapcore.Lock(zapcore.AddSync(ztest.FailWriter{})), |
| 596 | DebugLevel, |
| 597 | ), |
| 598 | ErrorOutput(errSink), |
| 599 | ) |
| 600 | |
| 601 | logger.Info("foo") |
| 602 | // Should log the error. |
| 603 | assert.Regexp(t, `write error: failed`, errSink.Stripped(), "Expected to log the error to the error output.") |
| 604 | assert.True(t, errSink.Called(), "Expected logging an internal error to call Sync the error sink.") |
| 605 | } |
| 606 | |
| 607 | func TestLoggerSync(t *testing.T) { |
| 608 | withLogger(t, DebugLevel, nil, func(logger *Logger, _ *observer.ObservedLogs) { |
nothing calls this directly
no test coverage detected