2021-09-07 17:09:30 +02:00
|
|
|
package errorsx
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"io"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
2021-09-07 20:39:32 +02:00
|
|
|
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")
|
|
|
|
}
|
|
|
|
})
|
2021-09-07 17:09:30 +02:00
|
|
|
|
2021-09-07 20:39:32 +02:00
|
|
|
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")
|
|
|
|
}
|
|
|
|
})
|
2021-09-07 17:09:30 +02:00
|
|
|
}
|