refactor: move i/e/n/errorx to i/errorsx (#416)
Still working towards https://github.com/ooni/probe/issues/1505
This commit is contained in:
@@ -4,7 +4,7 @@ import (
|
||||
"errors"
|
||||
"strings"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/errorx"
|
||||
"github.com/ooni/probe-cli/v3/internal/errorsx"
|
||||
)
|
||||
|
||||
// reduceErrors finds a known error in a list of errors since
|
||||
@@ -27,7 +27,7 @@ func reduceErrors(errorslist []error) error {
|
||||
// the user has no IPv6 connectivity, an IPv6 error is going to
|
||||
// appear later in the list of errors.
|
||||
for _, err := range errorslist {
|
||||
var wrapper *errorx.ErrWrapper
|
||||
var wrapper *errorsx.ErrWrapper
|
||||
if errors.As(err, &wrapper) && !strings.HasPrefix(
|
||||
err.Error(), "unknown_failure",
|
||||
) {
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/errorx"
|
||||
"github.com/ooni/probe-cli/v3/internal/errorsx"
|
||||
)
|
||||
|
||||
func TestReduceErrors(t *testing.T) {
|
||||
@@ -31,15 +31,15 @@ func TestReduceErrors(t *testing.T) {
|
||||
})
|
||||
t.Run("multiple errors with meaningful ones", func(t *testing.T) {
|
||||
err1 := errors.New("mocked error #1")
|
||||
err2 := &errorx.ErrWrapper{
|
||||
err2 := &errorsx.ErrWrapper{
|
||||
Failure: "unknown_failure: antani",
|
||||
}
|
||||
err3 := &errorx.ErrWrapper{
|
||||
Failure: errorx.FailureConnectionRefused,
|
||||
err3 := &errorsx.ErrWrapper{
|
||||
Failure: errorsx.FailureConnectionRefused,
|
||||
}
|
||||
err4 := errors.New("mocked error #3")
|
||||
result := reduceErrors([]error{err1, err2, err3, err4})
|
||||
if result.Error() != errorx.FailureConnectionRefused {
|
||||
if result.Error() != errorsx.FailureConnectionRefused {
|
||||
t.Fatal("wrong result")
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user