(t *testing.T)
| 796 | } |
| 797 | |
| 798 | func TestLoggerConcurrent(t *testing.T) { |
| 799 | withLogger(t, DebugLevel, nil, func(logger *Logger, logs *observer.ObservedLogs) { |
| 800 | child := logger.With(String("foo", "bar")) |
| 801 | |
| 802 | wg := &sync.WaitGroup{} |
| 803 | runConcurrently(5, 10, wg, func() { |
| 804 | logger.Info("", String("foo", "bar")) |
| 805 | }) |
| 806 | runConcurrently(5, 10, wg, func() { |
| 807 | child.Info("") |
| 808 | }) |
| 809 | |
| 810 | wg.Wait() |
| 811 | |
| 812 | // Make sure the output doesn't contain interspersed entries. |
| 813 | assert.Equal(t, 100, logs.Len(), "Unexpected number of logs written out.") |
| 814 | for _, obs := range logs.AllUntimed() { |
| 815 | assert.Equal( |
| 816 | t, |
| 817 | observer.LoggedEntry{ |
| 818 | Entry: zapcore.Entry{Level: InfoLevel}, |
| 819 | Context: []Field{String("foo", "bar")}, |
| 820 | }, |
| 821 | obs, |
| 822 | "Unexpected log output.", |
| 823 | ) |
| 824 | } |
| 825 | }) |
| 826 | } |
| 827 | |
| 828 | func TestLoggerFatalOnNoop(t *testing.T) { |
| 829 | exitStub := exit.Stub() |
nothing calls this directly
no test coverage detected