ax(mining): remove banned errors import from errors_test.go
Replace errors.New() with ErrInternal()/ErrTimeout() and errors.Unwrap(err) with err.Unwrap() — the MiningError type provides both without the banned import. Co-Authored-By: Charon <charon@lethean.io>
This commit is contained in:
parent
fc7a1a2147
commit
71292ccdc8
1 changed files with 3 additions and 4 deletions
|
|
@ -1,7 +1,6 @@
|
|||
package mining
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/http"
|
||||
"testing"
|
||||
)
|
||||
|
|
@ -17,14 +16,14 @@ func TestErrors_Error_Good(t *testing.T) {
|
|||
|
||||
// TestErrors_Error_Bad verifies the error string includes the underlying cause
|
||||
func TestErrors_Error_Bad(t *testing.T) {
|
||||
cause := errors.New("underlying error")
|
||||
cause := ErrInternal("underlying error")
|
||||
err := NewMiningError(ErrCodeStartFailed, "failed to start").WithCause(cause)
|
||||
|
||||
if err.Cause != cause {
|
||||
t.Error("Cause was not set")
|
||||
}
|
||||
|
||||
if errors.Unwrap(err) != cause {
|
||||
if err.Unwrap() != cause {
|
||||
t.Error("Unwrap did not return cause")
|
||||
}
|
||||
}
|
||||
|
|
@ -136,7 +135,7 @@ func TestErrors_PredefinedErrors_Good(t *testing.T) {
|
|||
|
||||
// TestErrors_Chaining_Ugly verifies error chaining survives multiple WithCause/WithDetails/WithSuggestion calls
|
||||
func TestErrors_Chaining_Ugly(t *testing.T) {
|
||||
cause := errors.New("network timeout")
|
||||
cause := ErrTimeout("network timeout")
|
||||
err := ErrConnectionFailed("pool:3333").
|
||||
WithCause(cause).
|
||||
WithDetails("timeout after 30s").
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue