MCPcopy
hub / github.com/uber-go/zap / TestCheckedEntryIllegalReuse

Function TestCheckedEntryIllegalReuse

zapcore/entry_ext_test.go:34–55  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

32)
33
34func TestCheckedEntryIllegalReuse(t *testing.T) {
35 t.Parallel()
36
37 var errOut bytes.Buffer
38
39 testCore := zaptest.NewLogger(t).Core()
40 ce := testCore.Check(zapcore.Entry{
41 Level: zapcore.InfoLevel,
42 Time: time.Now(),
43 Message: "hello",
44 }, nil)
45 ce.ErrorOutput = zapcore.AddSync(&errOut)
46
47 // The first write should succeed.
48 ce.Write(zap.String("k", "v"), zap.Int("n", 42))
49 assert.Empty(t, errOut.String(), "Expected no errors on first write.")
50
51 // The second write should fail.
52 ce.Write(zap.String("foo", "bar"), zap.Int("x", 1))
53 assert.Contains(t, errOut.String(), "Unsafe CheckedEntry re-use near Entry",
54 "Expected error logged on second write.")
55}

Callers

nothing calls this directly

Calls 9

StringMethod · 0.95
NewLoggerFunction · 0.92
AddSyncFunction · 0.92
StringFunction · 0.92
IntFunction · 0.92
CoreMethod · 0.80
CheckMethod · 0.65
NowMethod · 0.65
WriteMethod · 0.65

Tested by

no test coverage detected