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

@@ -9,6 +9,7 @@ import (
objects "github.com/d5/tengo/v2"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/thrasher-corp/gocryptotrader/common"
"github.com/thrasher-corp/gocryptotrader/exchanges/account"
"github.com/thrasher-corp/gocryptotrader/exchanges/asset"
@@ -348,9 +349,7 @@ func TestSetVerbose(t *testing.T) {
}
resp, err := setVerbose(&Context{})
if !errors.Is(err, nil) {
t.Fatalf("received: '%v' but expected: '%v'", err, nil)
}
require.NoError(t, err)
ctx, ok := objects.ToInterface(resp).(*Context)
if !ok {
@@ -408,9 +407,7 @@ func TestSetAccount(t *testing.T) {
}
resp, err := setAccount(&Context{}, dummyStr, dummyStr, dummyStr, dummyStr, dummyStr, dummyStr)
if !errors.Is(err, nil) {
t.Fatalf("received: '%v' but expected: '%v'", err, nil)
}
require.NoError(t, err)
ctx, ok := objects.ToInterface(resp).(*Context)
if !ok {
@@ -461,9 +458,7 @@ func TestSetSubAccount(t *testing.T) {
}
subby, err := setSubAccount(&Context{}, dummyStr)
if !errors.Is(err, nil) {
t.Fatalf("received: '%v' but expected: '%v'", err, nil)
}
require.NoError(t, err)
ctxWSubAcc, ok := subby.(*Context)
if !ok {
@@ -498,14 +493,10 @@ func TestProcessScriptContext(t *testing.T) {
}
fromScript, err := setAccount(&Context{}, dummyStr, dummyStr, dummyStr, dummyStr, dummyStr, dummyStr)
if !errors.Is(err, nil) {
t.Fatalf("received: '%v' but expected: '%v'", err, nil)
}
require.NoError(t, err)
fromScript, err = setVerbose(fromScript)
if !errors.Is(err, nil) {
t.Fatalf("received: '%v' but expected: '%v'", err, nil)
}
require.NoError(t, err)
scriptCTX, ok := objects.ToInterface(fromScript).(*Context)
if !ok {

View File

@@ -115,7 +115,7 @@ func TestRsi(t *testing.T) {
validator.IsTestExecution.Store(true)
ret, err := rsi(ohlcvData, &objects.Int{Value: 14})
require.NoError(t, err, "rsi should not throw an error")
require.NoError(t, err, "rsi must not throw an error")
assert.NotNil(t, ret)
validator.IsTestExecution.Store(false)