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

Function TestFieldsErrs

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

Source from the content-addressed store, hash-verified

332 }
333}
334func TestFieldsErrs(t *testing.T) {
335 var err error = nil
336 out := &bytes.Buffer{}
337 log := New(out)
338 log.Log().Fields(map[string]interface{}{
339 "errors": []error{errors.New("some error"), nil, err, loggableError{errors.New("loggable")}, nonLoggableError{fmt.Errorf("oops"), 404}},
340 }).Msg("")
341 if got, want := decodeIfBinaryToString(out.Bytes()), `{"errors":["some error",null,null,{"l":"LOGGABLE"},"oops"]}`+"\n"; got != want {
342 t.Errorf("invalid log output:\ngot: %v\nwant: %v", got, want)
343 }
344}
345
346func TestFieldsMapPnt(t *testing.T) {
347 out := &bytes.Buffer{}

Callers

nothing calls this directly

Calls 6

NewFunction · 0.85
MsgMethod · 0.80
decodeIfBinaryToStringFunction · 0.70
LogMethod · 0.65
FieldsMethod · 0.45
BytesMethod · 0.45

Tested by

no test coverage detected