MCPcopy
hub / github.com/sirupsen/logrus / TestAddHookRace

Function TestAddHookRace

hook_test.go:175–194  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

173}
174
175func TestAddHookRace(t *testing.T) {
176 var wg sync.WaitGroup
177 wg.Add(2)
178 hook := new(ErrorHook)
179 LogAndAssertJSON(t, func(log *Logger) {
180 go func() {
181 defer wg.Done()
182 log.AddHook(hook)
183 }()
184 go func() {
185 defer wg.Done()
186 log.Error("test")
187 }()
188 wg.Wait()
189 }, func(fields Fields) {
190 // the line may have been logged
191 // before the hook was added, so we can't
192 // actually assert on the hook
193 })
194}
195
196func TestAddHookRace2(t *testing.T) {
197 t.Parallel()

Callers

nothing calls this directly

Calls 4

LogAndAssertJSONFunction · 0.85
AddMethod · 0.80
AddHookMethod · 0.80
ErrorMethod · 0.65

Tested by

no test coverage detected