mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-22 23:16:48 +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,7 +1,6 @@
|
||||
package indicators
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"math/rand"
|
||||
"os"
|
||||
"reflect"
|
||||
@@ -55,9 +54,7 @@ func TestMain(m *testing.M) {
|
||||
func TestMfi(t *testing.T) {
|
||||
_, err := mfi()
|
||||
if err != nil {
|
||||
if !errors.Is(err, objects.ErrWrongNumArguments) {
|
||||
t.Error(err)
|
||||
}
|
||||
assert.ErrorIs(t, err, objects.ErrWrongNumArguments)
|
||||
}
|
||||
|
||||
v := &objects.String{Value: testString}
|
||||
@@ -124,9 +121,7 @@ func TestRsi(t *testing.T) {
|
||||
func TestEMA(t *testing.T) {
|
||||
_, err := ema()
|
||||
if err != nil {
|
||||
if !errors.Is(err, objects.ErrWrongNumArguments) {
|
||||
t.Error(err)
|
||||
}
|
||||
assert.ErrorIs(t, err, objects.ErrWrongNumArguments)
|
||||
}
|
||||
|
||||
v := &objects.String{Value: testString}
|
||||
@@ -166,9 +161,7 @@ func TestEMA(t *testing.T) {
|
||||
func TestSMA(t *testing.T) {
|
||||
_, err := sma()
|
||||
if err != nil {
|
||||
if !errors.Is(err, objects.ErrWrongNumArguments) {
|
||||
t.Error(err)
|
||||
}
|
||||
assert.ErrorIs(t, err, objects.ErrWrongNumArguments)
|
||||
}
|
||||
|
||||
v := &objects.String{Value: testString}
|
||||
@@ -208,9 +201,7 @@ func TestSMA(t *testing.T) {
|
||||
func TestMACD(t *testing.T) {
|
||||
_, err := macd()
|
||||
if err != nil {
|
||||
if !errors.Is(err, objects.ErrWrongNumArguments) {
|
||||
t.Error(err)
|
||||
}
|
||||
assert.ErrorIs(t, err, objects.ErrWrongNumArguments)
|
||||
}
|
||||
|
||||
v := &objects.String{Value: testString}
|
||||
@@ -256,9 +247,7 @@ func TestMACD(t *testing.T) {
|
||||
func TestAtr(t *testing.T) {
|
||||
_, err := atr()
|
||||
if err != nil {
|
||||
if !errors.Is(err, objects.ErrWrongNumArguments) {
|
||||
t.Error(err)
|
||||
}
|
||||
assert.ErrorIs(t, err, objects.ErrWrongNumArguments)
|
||||
}
|
||||
|
||||
v := &objects.String{Value: testString}
|
||||
@@ -298,9 +287,7 @@ func TestAtr(t *testing.T) {
|
||||
func TestBbands(t *testing.T) {
|
||||
_, err := bbands()
|
||||
if err != nil {
|
||||
if !errors.Is(err, objects.ErrWrongNumArguments) {
|
||||
t.Error(err)
|
||||
}
|
||||
assert.ErrorIs(t, err, objects.ErrWrongNumArguments)
|
||||
}
|
||||
|
||||
_, err = bbands(&objects.String{Value: testString}, ohlcvData,
|
||||
@@ -361,9 +348,7 @@ func TestBbands(t *testing.T) {
|
||||
&objects.Float{Value: 2.0},
|
||||
&objects.String{Value: testString})
|
||||
if err != nil {
|
||||
if !errors.Is(err, errInvalidSelector) {
|
||||
t.Error(err)
|
||||
}
|
||||
assert.ErrorIs(t, err, errInvalidSelector)
|
||||
}
|
||||
|
||||
_, err = bbands(objects.UndefinedValue, ohlcvData,
|
||||
@@ -379,9 +364,7 @@ func TestBbands(t *testing.T) {
|
||||
func TestOBV(t *testing.T) {
|
||||
_, err := obv()
|
||||
if err != nil {
|
||||
if !errors.Is(err, objects.ErrWrongNumArguments) {
|
||||
t.Error(err)
|
||||
}
|
||||
assert.ErrorIs(t, err, objects.ErrWrongNumArguments)
|
||||
}
|
||||
|
||||
_, err = obv(ohlcvData)
|
||||
|
||||
Reference in New Issue
Block a user