(t *testing.T)
| 56 | } |
| 57 | |
| 58 | func TestErrorArrayConstructor(t *testing.T) { |
| 59 | tests := []struct { |
| 60 | desc string |
| 61 | field Field |
| 62 | expected []interface{} |
| 63 | }{ |
| 64 | {"empty errors", Errors("", []error{}), []interface{}{}}, |
| 65 | { |
| 66 | "errors", |
| 67 | Errors("", []error{nil, errors.New("foo"), nil, errors.New("bar")}), |
| 68 | []interface{}{map[string]interface{}{"error": "foo"}, map[string]interface{}{"error": "bar"}}, |
| 69 | }, |
| 70 | } |
| 71 | |
| 72 | for _, tt := range tests { |
| 73 | enc := zapcore.NewMapObjectEncoder() |
| 74 | tt.field.Key = "k" |
| 75 | tt.field.AddTo(enc) |
| 76 | assert.Equal(t, tt.expected, enc.Fields["k"], "%s: unexpected map contents.", tt.desc) |
| 77 | assert.Equal(t, 1, len(enc.Fields), "%s: found extra keys in map: %v", tt.desc, enc.Fields) |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | func TestErrorsArraysHandleRichErrors(t *testing.T) { |
| 82 | errs := []error{fmt.Errorf("egad")} |
nothing calls this directly
no test coverage detected