MCPcopy
hub / github.com/rs/zerolog / TestEvent_DoneHandler

Function TestEvent_DoneHandler

event_test.go:416–437  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

414}
415
416func TestEvent_DoneHandler(t *testing.T) {
417 e := newEvent(nil, InfoLevel, false, nil, nil)
418
419 // Set up a done handler to capture calls
420 var called bool
421 var capturedMsg string
422 e.done = func(msg string) {
423 called = true
424 capturedMsg = msg
425 }
426
427 // Trigger msg via Msg
428 e.Msg("test message")
429
430 // Assert the handler was called with the correct message
431 if !called {
432 t.Error("Done handler was not called")
433 }
434 if capturedMsg != "test message" {
435 t.Errorf("Expected message 'test message', got '%s'", capturedMsg)
436 }
437}
438
439type badLevelWriter struct {
440 err error

Callers

nothing calls this directly

Calls 3

newEventFunction · 0.85
MsgMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected