mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-23 07:26:47 +00:00
codebase: Replace !errors.Is(err, target) with testify (#1931)
* tests: Replace !errors.Is(err, target) with testify equivalents * codebase: Manual !errors.Is(err, target) replacements * typo: Replace errMisMatchedEvent with errMismatchedEvent * tests: Enhance error messages for better output * tests: Refactor error assertions in various test cases to use require and improve clarity * misc linter: Fix assert should wording * tests: Simplify assertions in TestCreateSignals for clarity and conciseness * tests: Enhance assertion message in TestCreateSignals
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
package collateral
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/thrasher-corp/gocryptotrader/encoding/json"
|
||||
)
|
||||
|
||||
@@ -69,9 +69,8 @@ func TestUnmarshalJSONCollateralType(t *testing.T) {
|
||||
|
||||
jason = []byte(`{"collateral":"hello moto"}`)
|
||||
err = json.Unmarshal(jason, &alien)
|
||||
if !errors.Is(err, ErrInvalidCollateralMode) {
|
||||
t.Error(err)
|
||||
}
|
||||
assert.ErrorIs(t, err, ErrInvalidCollateralMode)
|
||||
|
||||
if alien.M != UnknownMode {
|
||||
t.Errorf("received '%v' expected 'UnknownMode'", alien.M)
|
||||
}
|
||||
@@ -143,9 +142,8 @@ func TestIsValidCollateralTypeString(t *testing.T) {
|
||||
func TestStringToCollateralType(t *testing.T) {
|
||||
t.Parallel()
|
||||
resp, err := StringToMode("lol")
|
||||
if !errors.Is(err, ErrInvalidCollateralMode) {
|
||||
t.Error(err)
|
||||
}
|
||||
assert.ErrorIs(t, err, ErrInvalidCollateralMode)
|
||||
|
||||
if resp != UnknownMode {
|
||||
t.Errorf("received '%v' expected '%v'", resp, UnknownMode)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user