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

Function TestPanicDisabled

log_test.go:1057–1074  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1055}
1056
1057func TestPanicDisabled(t *testing.T) {
1058 out := &bytes.Buffer{}
1059 log := New(out).Level(Disabled) // Disable all levels
1060
1061 // Call Panic, which should be disabled, call done, and panic with ""
1062 defer func() {
1063 if r := recover(); r == nil || r != "" {
1064 t.Errorf("Expected panic with empty string when Panic is disabled, got %v", r)
1065 }
1066 }()
1067 e := log.Panic()
1068 if e != nil {
1069 t.Error("Expected nil event when Panic is disabled")
1070 }
1071 if out.Len() > 0 {
1072 t.Errorf("Expected no output when Panic is disabled, got: %s", out.String())
1073 }
1074}
1075
1076func TestLoggerShouldWithNilWriter(t *testing.T) {
1077 // Create a logger with nil writer to test the should method's nil check

Callers

nothing calls this directly

Calls 5

NewFunction · 0.85
LevelMethod · 0.80
PanicMethod · 0.80
ErrorMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected