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

Function TestNopCore

zapcore/core_test.go:41–68  ·  zapcore/core_test.go::TestNopCore
(t *testing.T)

Source from the content-addressed store, hash-verified

39}
40
41func TestNopCore(t *testing.T) {
42 entry := Entry{
43 Message: "test",
44 Level: InfoLevel,
45 Time: time.Now(),
46 LoggerName: "main",
47 Stack: "fake-stack",
48 }
49 ce := &CheckedEntry{}
50
51 allLevels := []Level{
52 DebugLevel,
53 InfoLevel,
54 WarnLevel,
55 ErrorLevel,
56 DPanicLevel,
57 PanicLevel,
58 FatalLevel,
59 }
60 core := NewNopCore()
61 assert.Equal(t, core, core.With([]Field{makeInt64Field("k", 42)}), "Expected no-op With.")
62 for _, level := range allLevels {
63 assert.False(t, core.Enabled(level), "Expected all levels to be disabled in no-op core.")
64 assert.Equal(t, ce, core.Check(entry, ce), "Expected no-op Check to return checked entry unchanged.")
65 assert.NoError(t, core.Write(entry, nil), "Expected no-op Writes to always succeed.")
66 assert.NoError(t, core.Sync(), "Expected no-op Syncs to always succeed.")
67 }
68}
69
70func TestIOCore(t *testing.T) {
71 temp, err := os.CreateTemp(t.TempDir(), "test.log")

Callers

nothing calls this directly

Calls 8

NewNopCoreFunction · 0.85
makeInt64FieldFunction · 0.85
NowMethod · 0.65
WithMethod · 0.65
EnabledMethod · 0.65
CheckMethod · 0.65
WriteMethod · 0.65
SyncMethod · 0.65

Tested by

no test coverage detected