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

Function TestEmptyLevelFieldName

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

Source from the content-addressed store, hash-verified

81}
82
83func TestEmptyLevelFieldName(t *testing.T) {
84 fieldName := LevelFieldName
85 LevelFieldName = ""
86
87 t.Run("empty setting", func(t *testing.T) {
88 out := &bytes.Buffer{}
89 log := New(out)
90 log.Info().
91 Str("foo", "bar").
92 Int("n", 123).
93 Msg("")
94 if got, want := decodeIfBinaryToString(out.Bytes()), `{"foo":"bar","n":123}`+"\n"; got != want {
95 t.Errorf("invalid log output:\ngot: %v\nwant: %v", got, want)
96 }
97 })
98 LevelFieldName = fieldName
99}
100
101func TestWith(t *testing.T) {
102 out := &bytes.Buffer{}

Callers

nothing calls this directly

Calls 8

NewFunction · 0.85
MsgMethod · 0.80
decodeIfBinaryToStringFunction · 0.70
RunMethod · 0.65
InfoMethod · 0.65
IntMethod · 0.45
StrMethod · 0.45
BytesMethod · 0.45

Tested by

no test coverage detected