mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-08 23:16:54 +00:00
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:
@@ -151,18 +151,14 @@ func TestSupported(t *testing.T) {
|
||||
func TestUnmarshalMarshal(t *testing.T) {
|
||||
t.Parallel()
|
||||
data, err := json.Marshal(Item(0))
|
||||
if !errors.Is(err, nil) {
|
||||
t.Fatalf("received: '%v' but expected: '%v'", err, nil)
|
||||
}
|
||||
require.NoError(t, err)
|
||||
|
||||
if string(data) != `""` {
|
||||
t.Fatal("unexpected value")
|
||||
}
|
||||
|
||||
data, err = json.Marshal(Spot)
|
||||
if !errors.Is(err, nil) {
|
||||
t.Fatalf("received: '%v' but expected: '%v'", err, nil)
|
||||
}
|
||||
require.NoError(t, err)
|
||||
|
||||
if string(data) != `"spot"` {
|
||||
t.Fatal("unexpected value")
|
||||
@@ -171,9 +167,7 @@ func TestUnmarshalMarshal(t *testing.T) {
|
||||
var spot Item
|
||||
|
||||
err = json.Unmarshal(data, &spot)
|
||||
if !errors.Is(err, nil) {
|
||||
t.Fatalf("received: '%v' but expected: '%v'", err, nil)
|
||||
}
|
||||
require.NoError(t, err)
|
||||
|
||||
if spot != Spot {
|
||||
t.Fatal("unexpected value")
|
||||
@@ -185,14 +179,10 @@ func TestUnmarshalMarshal(t *testing.T) {
|
||||
}
|
||||
|
||||
err = json.Unmarshal([]byte(`""`), &spot)
|
||||
if !errors.Is(err, nil) {
|
||||
t.Fatalf("received: '%v' but expected: '%v'", err, nil)
|
||||
}
|
||||
require.NoError(t, err)
|
||||
|
||||
err = json.Unmarshal([]byte(`123`), &spot)
|
||||
if errors.Is(err, nil) {
|
||||
t.Fatalf("received: '%v' but expected: '%v'", nil, "an error")
|
||||
}
|
||||
assert.Error(t, err, "Unmarshal should error correctly")
|
||||
}
|
||||
|
||||
func TestUseDefault(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user