| 414 | } |
| 415 | |
| 416 | func 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 | |
| 439 | type badLevelWriter struct { |
| 440 | err error |