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
This commit is contained in:
parent
323266da83
commit
a56b284b0e
11 changed files with 346 additions and 135 deletions
|
|
@ -6,19 +6,21 @@ import (
|
|||
"testing"
|
||||
)
|
||||
|
||||
func TestErrWrapperError(t *testing.T) {
|
||||
err := &ErrWrapper{Failure: FailureDNSNXDOMAINError}
|
||||
if err.Error() != FailureDNSNXDOMAINError {
|
||||
t.Fatal("invalid return value")
|
||||
}
|
||||
}
|
||||
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")
|
||||
}
|
||||
})
|
||||
|
||||
func TestErrWrapperUnwrap(t *testing.T) {
|
||||
err := &ErrWrapper{
|
||||
Failure: FailureEOFError,
|
||||
WrappedErr: io.EOF,
|
||||
}
|
||||
if !errors.Is(err, io.EOF) {
|
||||
t.Fatal("cannot unwrap error")
|
||||
}
|
||||
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")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue