64de635626
As we have a hard time figuring out what moby/moby#46099 should look like, this drop-in replacement will solve the initial formatting problem we have. It's made internal such that we can remove it whenever we want and unlike moby/moby#46099 doesn't require thoughtful API changes. Signed-off-by: Albin Kerouanton <albinker@gmail.com> Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
25 lines
585 B
Go
25 lines
585 B
Go
package multierror
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"testing"
|
|
|
|
"gotest.tools/v3/assert"
|
|
)
|
|
|
|
func TestErrorJoin(t *testing.T) {
|
|
t.Run("single", func(t *testing.T) {
|
|
err := Join(fmt.Errorf("invalid config: %w", Join(errors.New("foo"))))
|
|
const expected = `invalid config: foo`
|
|
assert.Equal(t, err.Error(), expected)
|
|
})
|
|
t.Run("multiple", func(t *testing.T) {
|
|
err := Join(errors.New("foobar"), fmt.Errorf("invalid config: \n%w", Join(errors.New("foo"), errors.New("bar"))))
|
|
const expected = `* foobar
|
|
* invalid config:
|
|
* foo
|
|
* bar`
|
|
assert.Equal(t, err.Error(), expected)
|
|
})
|
|
}
|