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

Function TestEvent_CallerRuntimeFail

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

Source from the content-addressed store, hash-verified

397}
398
399func TestEvent_CallerRuntimeFail(t *testing.T) {
400 var buf bytes.Buffer
401 e := newEvent(LevelWriterAdapter{&buf}, DebugLevel, false, nil, nil)
402
403 // Set a very large skipFrame to make runtime.Caller fail
404 e.CallerSkipFrame(1000)
405 e.Caller()
406
407 e.Msg("test")
408
409 got := strings.TrimSpace(buf.String())
410 want := `{"message":"test"}` // No caller field because runtime.Caller failed
411 if got != want {
412 t.Errorf("Event.Caller() with failed runtime.Caller = %q, want %q", got, want)
413 }
414}
415
416func TestEvent_DoneHandler(t *testing.T) {
417 e := newEvent(nil, InfoLevel, false, nil, nil)

Callers

nothing calls this directly

Calls 5

newEventFunction · 0.85
CallerSkipFrameMethod · 0.80
MsgMethod · 0.80
CallerMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected