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

@@ -68,11 +68,11 @@ func ({{.Variable}} *{{.CapitalName}}) SetDefaults() {
err = {{.Variable}}.SetAssetPairStore(asset.Spot, fmt1)
if err != nil {
log.Errorf(log.ExchangeSys, "%s error storing `%s` default asset formats: %s", {{.Variable}}.Name, asset.Spot, err)
log.Errorf(log.ExchangeSys, "%s error storing %q default asset formats: %s", {{.Variable}}.Name, asset.Spot, err)
}
err = {{.Variable}}.SetAssetPairStore(asset.Margin, fmt2)
if err != nil {
log.Errorf(log.ExchangeSys, "%s error storing `%s` default asset formats: %s", {{.Variable}}.Name, asset.Margin, err)
log.Errorf(log.ExchangeSys, "%s error storing %q default asset formats: %s", {{.Variable}}.Name, asset.Margin, err)
}
// Fill out the capabilities/features that the exchange supports

View File

@@ -104,7 +104,7 @@ func setupExchange(ctx context.Context, t *testing.T, name string, cfg *config.C
b := exch.GetBase()
assets := b.CurrencyPairs.GetAssetTypes(false)
require.NotEmpty(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)
}

View File

@@ -29,7 +29,7 @@ func isFuturesAsset(a string) error {
return err
}
if !i.IsFutures() {
return fmt.Errorf("%w '%s'", futures.ErrNotFuturesAsset, a)
return fmt.Errorf("%w %q", futures.ErrNotFuturesAsset, a)
}
return nil
}

View File

@@ -85,8 +85,8 @@ func main() {
}
listenAddr := cfg.RemoteControl.WebsocketRPC.ListenAddress
wsHost := fmt.Sprintf("ws://%s/ws", net.JoinHostPort(common.ExtractHost(listenAddr),
strconv.Itoa(common.ExtractPort(listenAddr))))
wsHost := fmt.Sprintf("ws://%s/ws", net.JoinHostPort(common.ExtractHostOrDefault(listenAddr),
strconv.Itoa(common.ExtractPortOrDefault(listenAddr))))
log.Printf("Connecting to websocket host: %s", wsHost)
var dialer gws.Dialer