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:
Adrian Gallagher
2025-06-10 16:29:57 +10:00
committed by GitHub
parent 122ab2f849
commit 19b8957f3f
109 changed files with 2485 additions and 5670 deletions

View File

@@ -2,7 +2,6 @@ package bitfinex
import (
"bufio"
"errors"
"log"
"os"
"strconv"
@@ -130,9 +129,7 @@ func TestGetPairs(t *testing.T) {
t.Parallel()
_, err := b.GetPairs(t.Context(), asset.Binary)
if !errors.Is(err, asset.ErrNotSupported) {
t.Fatalf("received: '%v' but expected: '%v'", err, asset.ErrNotSupported)
}
require.ErrorIs(t, err, asset.ErrNotSupported)
assets := b.GetAssetTypes(false)
for x := range assets {
@@ -1697,17 +1694,13 @@ func TestFixCasing(t *testing.T) {
}
_, err = b.fixCasing(currency.NewPair(currency.EMPTYCODE, currency.BTC), asset.MarginFunding)
if !errors.Is(err, currency.ErrCurrencyPairEmpty) {
t.Fatalf("received: '%v' but expected: '%v'", err, currency.ErrCurrencyPairEmpty)
}
require.ErrorIs(t, err, currency.ErrCurrencyPairEmpty)
_, err = b.fixCasing(currency.NewPair(currency.BTC, currency.EMPTYCODE), asset.MarginFunding)
require.NoError(t, err)
_, err = b.fixCasing(currency.EMPTYPAIR, asset.MarginFunding)
if !errors.Is(err, currency.ErrCurrencyPairEmpty) {
t.Fatalf("received: '%v' but expected: '%v'", err, currency.ErrCurrencyPairEmpty)
}
require.ErrorIs(t, err, currency.ErrCurrencyPairEmpty)
}
func Test_FormatExchangeKlineInterval(t *testing.T) {
@@ -1931,9 +1924,7 @@ func TestGetSiteListConfigData(t *testing.T) {
t.Parallel()
_, err := b.GetSiteListConfigData(t.Context(), "")
if !errors.Is(err, errSetCannotBeEmpty) {
t.Fatalf("received: %v, expected: %v", err, errSetCannotBeEmpty)
}
require.ErrorIs(t, err, errSetCannotBeEmpty)
pairs, err := b.GetSiteListConfigData(t.Context(), bitfinexSecuritiesPairs)
require.NoError(t, err)