| 62 | } |
| 63 | |
| 64 | func TestMultiError_Err(t *testing.T) { |
| 65 | tests := []struct { |
| 66 | name string |
| 67 | errs []error |
| 68 | expectNil bool |
| 69 | }{ |
| 70 | { |
| 71 | name: "empty returns nil", |
| 72 | errs: nil, |
| 73 | expectNil: true, |
| 74 | }, |
| 75 | { |
| 76 | name: "with errors returns non-nil", |
| 77 | errs: []error{errors.New("err1")}, |
| 78 | expectNil: false, |
| 79 | }, |
| 80 | } |
| 81 | |
| 82 | for _, tt := range tests { |
| 83 | t.Run(tt.name, func(t *testing.T) { |
| 84 | me := New(tt.errs...) |
| 85 | result := me.Err() |
| 86 | if tt.expectNil { |
| 87 | assert.NoError(t, result) |
| 88 | } else { |
| 89 | assert.Error(t, result) |
| 90 | } |
| 91 | }) |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | func TestNonNilMultiError_Error(t *testing.T) { |
| 96 | tests := []struct { |