Skip to content

Commit

Permalink
Remove TestMultierror
Browse files Browse the repository at this point in the history
  • Loading branch information
inancgumus committed Feb 14, 2024
1 parent e3fa370 commit de8e7ba
Showing 1 changed file with 0 additions and 73 deletions.
73 changes: 0 additions & 73 deletions common/remote_object_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package common

import (
"encoding/json"
"errors"
"fmt"
"math"
"testing"

Expand Down Expand Up @@ -263,74 +261,3 @@ func TestParseRemoteObject(t *testing.T) {
})
}
}

func TestMultierror(t *testing.T) {
t.Parallel()

var (
mockErr1 = errors.New("mockErr1")
mockErr2 = errors.New("mockErr2")
mockErr3 = errors.New("mockErr3")

mockMultiErr = &multiError{
Errors: []error{mockErr1},
}
mockWrappedMultiErr = fmt.Errorf("%w", mockMultiErr)
)

tests := []struct {
name string
initial error
errs []error
exp []error
expStr string
}{
{
name: "initial error is nil",
initial: nil,
errs: []error{mockErr1},
exp: []error{mockErr1},
expStr: mockErr1.Error(),
},
{
name: "initial error is std error",
initial: mockErr1,
errs: []error{mockErr2, mockErr3},
exp: []error{mockErr1, mockErr2, mockErr3},
expStr: fmt.Sprintf(
"3 errors occurred:\n\t* %s\n\t* %s\n\t* %s\n",
mockErr1, mockErr2, mockErr3),
},
{
name: "initial error is multiError",
initial: mockMultiErr,
errs: []error{mockErr3},
exp: []error{mockErr1, mockErr3},
expStr: fmt.Sprintf(
"2 errors occurred:\n\t* %s\n\t* %s\n",
mockErr1, mockErr3),
},
{
name: "initial error is wrapped multiError",
initial: mockWrappedMultiErr,
errs: []error{mockErr3, mockErr2},
exp: []error{mockWrappedMultiErr, mockErr3, mockErr2},
expStr: fmt.Sprintf(
"3 errors occurred:\n\t* %s\n\t* %s\n\t* %s\n",
mockWrappedMultiErr, mockErr3, mockErr2),
},
}

for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

err := multierror(tc.initial, tc.errs...)
var me *multiError
assert.True(t, errors.As(err, &me))
assert.Equal(t, tc.exp, me.Errors)
assert.Equal(t, tc.expStr, me.Error())
})
}
}

0 comments on commit de8e7ba

Please sign in to comment.