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

@@ -98,15 +98,13 @@ func setupExchange(ctx context.Context, t *testing.T, name string, cfg *config.C
}
err = exch.UpdateTradablePairs(ctx, true)
if err != nil && !errors.Is(err, context.DeadlineExceeded) {
t.Fatalf("Cannot setup %v UpdateTradablePairs %v", name, err)
}
require.Truef(t, errors.Is(err, context.DeadlineExceeded) || err == nil, "Exchange %s UpdateTradablePairs must not error: %s", name, err)
b := exch.GetBase()
assets := b.CurrencyPairs.GetAssetTypes(false)
require.NotEmptyf(t, assets, "exchange %s must have assets", name)
require.NotEmptyf(t, assets, "Exchange %s must have assets", name)
for _, a := range assets {
require.NoErrorf(t, b.CurrencyPairs.SetAssetEnabled(a, true), "exchange %s SetAssetEnabled must not error for %s", name, a)
require.NoErrorf(t, b.CurrencyPairs.SetAssetEnabled(a, true), "Exchange %s SetAssetEnabled must not error for asset %s: %s", name, a, err)
}
// Add +1 to len to verify that exchanges can handle requests with unset pairs and assets
@@ -127,9 +125,7 @@ assets:
t.Fatalf("Cannot setup %v asset %v getPairFromPairs %v", name, assets[j], err)
}
err = b.CurrencyPairs.EnablePair(assets[j], p)
if err != nil && !errors.Is(err, currency.ErrPairAlreadyEnabled) {
t.Fatalf("Cannot setup %v asset %v EnablePair %v", name, assets[j], err)
}
require.Truef(t, errors.Is(err, currency.ErrPairAlreadyEnabled) || err == nil, "Exchange %s EnablePair must not error for %s", name, p)
p, err = b.FormatExchangeCurrency(p, assets[j])
if err != nil {
t.Fatalf("Cannot setup %v asset %v FormatExchangeCurrency %v", name, assets[j], err)