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

Function TestErrArrayBrokenEncoder

zapcore/error_test.go:182–205  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

180}
181
182func TestErrArrayBrokenEncoder(t *testing.T) {
183 t.Parallel()
184
185 f := Field{
186 Key: "foo",
187 Type: ErrorType,
188 Interface: multierr.Combine(
189 errors.New("foo"),
190 errors.New("bar"),
191 ),
192 }
193
194 failWith := errors.New("great sadness")
195 enc := NewMapObjectEncoder()
196 f.AddTo(brokenArrayObjectEncoder{
197 Err: failWith,
198 ObjectEncoder: enc,
199 })
200
201 // Failure to add the field to the encoder
202 // causes the error to be added as a string field.
203 assert.Equal(t, "great sadness", enc.Fields["fooError"],
204 "Unexpected error message.")
205}
206
207// brokenArrayObjectEncoder is an ObjectEncoder
208// that builds a broken ArrayEncoder.

Callers

nothing calls this directly

Calls 2

AddToMethod · 0.95
NewMapObjectEncoderFunction · 0.85

Tested by

no test coverage detected