milvus/internal/util/errutil/errors_test.go
yah01 21eea923cc
Add util to combine multiple errors so everyone checkable (#22473)
Signed-off-by: yah01 <yang.cen@zilliz.com>
2023-02-28 19:35:47 +08:00

32 lines
546 B
Go

package errutil
import (
"testing"
"github.com/cockroachdb/errors"
"github.com/stretchr/testify/suite"
)
type ErrSuite struct {
suite.Suite
}
func (s *ErrSuite) TestCombine() {
var (
errFirst = errors.New("first")
errSecond = errors.New("second")
errThird = errors.New("third")
)
err := Combine(errFirst, errSecond)
s.True(errors.Is(err, errFirst))
s.True(errors.Is(err, errSecond))
s.False(errors.Is(err, errThird))
s.Equal("first: second", err.Error())
}
func TestErrors(t *testing.T) {
suite.Run(t, new(ErrSuite))
}