(t *testing.T)
| 40 | } |
| 41 | |
| 42 | func TestLoggingWithHooksRace(t *testing.T) { |
| 43 | |
| 44 | r := rand.New(rand.NewSource(time.Now().UnixNano())) |
| 45 | unlocker := r.Intn(100) |
| 46 | |
| 47 | assert := assert.New(t) |
| 48 | logger, hook := NewNullLogger() |
| 49 | |
| 50 | var wgOne, wgAll sync.WaitGroup |
| 51 | wgOne.Add(1) |
| 52 | wgAll.Add(100) |
| 53 | |
| 54 | for i := 0; i < 100; i++ { |
| 55 | go func(i int) { |
| 56 | logger.Info("info") |
| 57 | wgAll.Done() |
| 58 | if i == unlocker { |
| 59 | wgOne.Done() |
| 60 | } |
| 61 | }(i) |
| 62 | } |
| 63 | |
| 64 | wgOne.Wait() |
| 65 | |
| 66 | assert.Equal(logrus.InfoLevel, hook.LastEntry().Level) |
| 67 | assert.Equal("info", hook.LastEntry().Message) |
| 68 | |
| 69 | wgAll.Wait() |
| 70 | |
| 71 | entries := hook.AllEntries() |
| 72 | assert.Equal(100, len(entries)) |
| 73 | } |
| 74 | |
| 75 | func TestFatalWithAlternateExit(t *testing.T) { |
| 76 | assert := assert.New(t) |
nothing calls this directly
no test coverage detected