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

Function TestUpdateEmptyContext

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

Source from the content-addressed store, hash-verified

1248}
1249
1250func TestUpdateEmptyContext(t *testing.T) {
1251 var buf bytes.Buffer
1252 log := New(&buf)
1253
1254 log.UpdateContext(func(c Context) Context {
1255 return c.Str("foo", "bar")
1256 })
1257 log.Info().Msg("no panic")
1258
1259 want := `{"level":"info","foo":"bar","message":"no panic"}` + "\n"
1260
1261 if got := decodeIfBinaryToString(buf.Bytes()); got != want {
1262 t.Errorf("invalid log output:\ngot: %q\nwant: %q", got, want)
1263 }
1264}
1265
1266func TestUpdateContextOnDisabledLogger(t *testing.T) {
1267 var buf bytes.Buffer

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…