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

Function TestErrArrayBrokenEncoder

error_test.go:99–112  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

97}
98
99func TestErrArrayBrokenEncoder(t *testing.T) {
100 t.Parallel()
101
102 failWith := errors.New("great sadness")
103 err := (brokenArrayObjectEncoder{
104 Err: failWith,
105 ObjectEncoder: zapcore.NewMapObjectEncoder(),
106 }).AddArray("errors", errArray{
107 errors.New("foo"),
108 errors.New("bar"),
109 })
110 require.Error(t, err, "Expected error from broken encoder.")
111 assert.ErrorIs(t, err, failWith, "Unexpected error.")
112}
113
114// brokenArrayObjectEncoder is an ObjectEncoder
115// that builds a broken ArrayEncoder.

Callers

nothing calls this directly

Calls 3

NewMapObjectEncoderFunction · 0.92
AddArrayMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected