ooni-probe-cli/internal/netxlite/errorsx/errwrapper_test.go
Simone Basso a56b284b0e
refactor(netxlite/errors): improve docs and format code (#481)
No real functional change. A few are needed and they will come
next. With this diff I just wanted to do cosmetic changes and
documentation changes, to ensure this package is okay.

See https://github.com/ooni/probe/issues/1591
2021-09-07 20:39:32 +02:00

27 lines
468 B
Go

package errorsx
import (
"errors"
"io"
"testing"
)
func TestErrWrapper(t *testing.T) {
t.Run("Error", func(t *testing.T) {
err := &ErrWrapper{Failure: FailureDNSNXDOMAINError}
if err.Error() != FailureDNSNXDOMAINError {
t.Fatal("invalid return value")
}
})
t.Run("Unwrap", func(t *testing.T) {
err := &ErrWrapper{
Failure: FailureEOFError,
WrappedErr: io.EOF,
}
if !errors.Is(err, io.EOF) {
t.Fatal("cannot unwrap error")
}
})
}