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

Function TestIOCoreSyncsOutput

zapcore/core_test.go:130–155  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

128}
129
130func TestIOCoreSyncsOutput(t *testing.T) {
131 tests := []struct {
132 entry Entry
133 shouldSync bool
134 }{
135 {Entry{Level: DebugLevel}, false},
136 {Entry{Level: InfoLevel}, false},
137 {Entry{Level: WarnLevel}, false},
138 {Entry{Level: ErrorLevel}, false},
139 {Entry{Level: DPanicLevel}, true},
140 {Entry{Level: PanicLevel}, true},
141 {Entry{Level: FatalLevel}, true},
142 }
143
144 for _, tt := range tests {
145 sink := &ztest.Discarder{}
146 core := NewCore(
147 NewJSONEncoder(testEncoderConfig()),
148 sink,
149 DebugLevel,
150 )
151
152 assert.NoError(t, core.Write(tt.entry, nil), "Unexpected error writing entry.")
153 assert.Equal(t, tt.shouldSync, sink.Called(), "Incorrect Sync behavior.")
154 }
155}
156
157func TestIOCoreWriteFailure(t *testing.T) {
158 core := NewCore(

Callers

nothing calls this directly

Calls 5

WriteMethod · 0.95
NewCoreFunction · 0.85
NewJSONEncoderFunction · 0.85
testEncoderConfigFunction · 0.85
CalledMethod · 0.80

Tested by

no test coverage detected