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

@@ -26,7 +26,7 @@ type mockExWithSubValidator struct {
func (m *mockExWithSubValidator) ValidateSubscriptions(in List) error {
for _, sub := range in {
if sub.Channel == "fail-channel" {
return fmt.Errorf("%w: '%s'", errValidateSubscriptionsTestError, sub.String())
return fmt.Errorf("%w: %q", errValidateSubscriptionsTestError, sub.String())
}
}
return nil

View File

@@ -101,7 +101,7 @@ func TestSubscriptionClone(t *testing.T) {
}
a.EnsureKeyed()
b := a.Clone()
assert.IsType(t, new(Subscription), b, "Clone must return a Subscription pointer")
assert.IsType(t, new(Subscription), b, "Clone should return a Subscription pointer")
assert.NotSame(t, a, b, "Clone should return a new Subscription")
assert.Nil(t, b.Key, "Clone should have a nil key")
b.Pairs[0].Delimiter = "🐳"
@@ -111,7 +111,7 @@ func TestSubscriptionClone(t *testing.T) {
assert.NotEqual(t, params, b.Params, "Params should be cloned")
assert.Equal(t, params, a.Params, "Original Params should be left alone")
a.m.Lock()
assert.True(t, b.m.TryLock(), "Clone must use a different Mutex")
assert.True(t, b.m.TryLock(), "Clone should use a different Mutex")
}
// TestSetKey exercises SetKey