GHA: Add additional checks for common issues (#1922)

* GHA, tests: Add additional checks for common issues

These checks include:
- Ensuring that all testify funcs use their formatted variants (e.g., `assert.Equalf(t, expected, actual)` instead of `assert.Equal(t, expected, actual)`).
- Replacing `%s` with %q
- Enforcing consistent usage of should/must wording for testify assert/require messages

* Add support for checking backticked string format specifiers and fix issues

* tests: Fix error comparisons

* tests: Replace errors.Is(err, nil) usage with testify and automate check

* refactor: Rename ExtractPort to ExtractPortOrDefault

* tests: Replace assert with require for error handling in multiple test files

* tests: Replace assert with require for error handling and improve assertions in data tests

* tests: Fix typo in assertion message for StreamVol test

* OKX: Fix GetOpenInterestAndVolumeStrike test with instrument selection and improved assertions

* OKX: Revert intentional error check

* Improve error message for expiry time check in GetOpenInterestAndVolumeStrike test
This commit is contained in:
Adrian Gallagher
2025-05-28 12:26:51 +10:00
committed by GitHub
parent 1e5739dffa
commit a5b638bfb7
165 changed files with 2565 additions and 4626 deletions

View File

@@ -4117,7 +4117,7 @@ func TestGetValidatedCurrencyCode(t *testing.T) {
}
for x := range pairs {
result := getValidatedCurrencyCode(x)
require.Equal(t, pairs[x], result, "expected: %s actual : %s for currency pair: %v", x, result, pairs[x])
require.Equalf(t, pairs[x], result, "expected: %s actual : %s for currency pair: %v", x, result, pairs[x])
}
}
@@ -4129,8 +4129,8 @@ func TestGetCurrencyTradeURL(t *testing.T) {
for _, a := range d.GetAssetTypes(false) {
var pairs currency.Pairs
pairs, err = d.CurrencyPairs.GetPairs(a, false)
require.NoError(t, err, "cannot get pairs for %s", a)
require.NotEmpty(t, pairs, "no pairs for %s", a)
require.NoErrorf(t, err, "cannot get pairs for %s", a)
require.NotEmptyf(t, pairs, "no pairs for %s", a)
var resp string
resp, err = d.GetCurrencyTradeURL(t.Context(), a, pairs[0])
require.NoError(t, err)

View File

@@ -855,7 +855,7 @@ func (d *Deribit) handleSubscription(method string, subs subscription.List) erro
}
for key := range subAck {
err = common.AppendError(err, fmt.Errorf("unexpected channel `%s` in result", key))
err = common.AppendError(err, fmt.Errorf("unexpected channel %q in result", key))
}
return err

View File

@@ -44,11 +44,11 @@ func (d *Deribit) SetDefaults() {
dashFormat := &currency.PairFormat{Uppercase: true, Delimiter: currency.DashDelimiter}
underscoreFormat := &currency.PairFormat{Uppercase: true, Delimiter: currency.UnderscoreDelimiter}
if err := d.SetAssetPairStore(asset.Spot, currency.PairStore{AssetEnabled: true, RequestFormat: underscoreFormat, ConfigFormat: underscoreFormat}); err != nil {
log.Errorf(log.ExchangeSys, "%s error storing `%s` default asset formats: %s", d.Name, asset.Spot, err)
log.Errorf(log.ExchangeSys, "%s error storing %q default asset formats: %s", d.Name, asset.Spot, err)
}
for _, a := range []asset.Item{asset.Futures, asset.Options, asset.OptionCombo, asset.FutureCombo} {
if err := d.SetAssetPairStore(a, currency.PairStore{AssetEnabled: true, RequestFormat: dashFormat, ConfigFormat: dashFormat}); err != nil {
log.Errorf(log.ExchangeSys, "%s error storing `%s` default asset formats: %s", d.Name, a, err)
log.Errorf(log.ExchangeSys, "%s error storing %q default asset formats: %s", d.Name, a, err)
}
}
@@ -1447,7 +1447,7 @@ func (d *Deribit) GetLatestFundingRates(ctx context.Context, r *fundingrate.Late
return nil, err
}
if !isPerpetual {
return nil, fmt.Errorf("%w '%s'", futures.ErrNotPerpetualFuture, r.Pair)
return nil, fmt.Errorf("%w %q", futures.ErrNotPerpetualFuture, r.Pair)
}
pFmt, err := d.CurrencyPairs.GetFormat(r.Asset, true)
if err != nil {