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

Function TestDiscard

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

Source from the content-addressed store, hash-verified

835}
836
837func TestDiscard(t *testing.T) {
838 out := &bytes.Buffer{}
839 log := New(out)
840 log.Log().Discard().Str("a", "b").Msgf("one %s %.1f %d %v", "two", 3.4, 5, errors.New("six"))
841 if got, want := decodeIfBinaryToString(out.Bytes()), ""; got != want {
842 t.Errorf("invalid log output:\ngot: %v\nwant: %v", got, want)
843 }
844
845 // Double call
846 log.Log().Discard().Discard().Str("a", "b").Msgf("one %s %.1f %d %v", "two", 3.4, 5, errors.New("six"))
847 if got, want := decodeIfBinaryToString(out.Bytes()), ""; got != want {
848 t.Errorf("invalid log output:\ngot: %v\nwant: %v", got, want)
849 }
850}
851
852type levelWriter struct {
853 ops []struct {

Callers

nothing calls this directly

Calls 7

NewFunction · 0.85
MsgfMethod · 0.80
DiscardMethod · 0.80
decodeIfBinaryToStringFunction · 0.70
LogMethod · 0.65
StrMethod · 0.45
BytesMethod · 0.45

Tested by

no test coverage detected