mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 15:09:42 +00:00
tests: Fix various issues (#1634)
* GateIO: Align struct for int64 usage * CI/build: Skip specific tests when run under Docker * slippage: Fix TestRandomSlippage intermittent issue
This commit is contained in:
2
.github/workflows/tests.yml
vendored
2
.github/workflows/tests.yml
vendored
@@ -144,7 +144,7 @@ jobs:
|
||||
|
||||
- name: Run Docker image
|
||||
run: |
|
||||
docker run --platform linux/arm64 --env SKIP_WRAPPER_CI_TESTS=true --env CI=true --rm gct-backend-arm64
|
||||
docker run --platform linux/arm64 --env SKIP_WRAPPER_CI_TESTS=true --env CI=true --env GCT_DOCKER_CI=true --rm gct-backend-arm64
|
||||
|
||||
frontend:
|
||||
name: GoCryptoTrader front-end
|
||||
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
func TestRandomSlippage(t *testing.T) {
|
||||
t.Parallel()
|
||||
resp := EstimateSlippagePercentage(decimal.NewFromInt(80), decimal.NewFromInt(100))
|
||||
assert.True(t, resp.GreaterThan(decimal.NewFromFloat(0.8)), "result should be more than 0.8")
|
||||
assert.True(t, resp.GreaterThanOrEqual(decimal.NewFromFloat(0.8)), "result should be greater than or equal to 0.8")
|
||||
assert.True(t, resp.LessThan(decimal.NewFromInt(1)), "result should be less than 1")
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,9 @@ import (
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestWrite(t *testing.T) {
|
||||
@@ -260,16 +263,13 @@ func TestWriter(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestWriterNoPermissionFails(t *testing.T) {
|
||||
if runtime.GOOS == "windows" {
|
||||
t.Skip("Skip file permissions")
|
||||
}
|
||||
temp := t.TempDir()
|
||||
err := os.Chmod(temp, 0o555)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
_, err = Writer(filepath.Join(temp, "path", "to", "somefile"))
|
||||
if err == nil {
|
||||
t.Error("Expected to fail when no permissions, but writer succeeded")
|
||||
if runtime.GOOS == "windows" || os.Getenv("GCT_DOCKER_CI") == "true" {
|
||||
t.Skip("Skipping file permission test on Windows or in Docker CI")
|
||||
}
|
||||
|
||||
tempDir := t.TempDir()
|
||||
err := os.Chmod(tempDir, 0o555)
|
||||
require.NoError(t, err, "Chmod should not fail to set read-only permissions")
|
||||
_, err = Writer(filepath.Join(tempDir, "path", "to", "somefile"))
|
||||
assert.Error(t, err, "Writer should fail with no write permissions")
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/thrasher-corp/gocryptotrader/common"
|
||||
"github.com/thrasher-corp/gocryptotrader/common/convert"
|
||||
"github.com/thrasher-corp/gocryptotrader/common/file"
|
||||
@@ -1850,25 +1851,12 @@ func TestCheckConfig(t *testing.T) {
|
||||
|
||||
func TestUpdateConfig(t *testing.T) {
|
||||
var c Config
|
||||
err := c.LoadConfig(TestFile, true)
|
||||
if err != nil {
|
||||
t.Errorf("%s", err)
|
||||
}
|
||||
|
||||
require.NoError(t, c.LoadConfig(TestFile, true), "LoadConfig should not error")
|
||||
newCfg := c
|
||||
err = c.UpdateConfig(TestFile, &newCfg, true)
|
||||
if err != nil {
|
||||
t.Fatalf("%s", err)
|
||||
}
|
||||
require.NoError(t, c.UpdateConfig(TestFile, &newCfg, true), "UpdateConfig should not error")
|
||||
|
||||
err = c.UpdateConfig("//non-existantpath\\", &newCfg, false)
|
||||
if err == nil {
|
||||
t.Fatalf("Error should have been thrown for invalid path")
|
||||
}
|
||||
|
||||
err = c.UpdateConfig(TestFile, &newCfg, true)
|
||||
if err != nil {
|
||||
t.Errorf("%s", err)
|
||||
if isGCTDocker := os.Getenv("GCT_DOCKER_CI"); isGCTDocker != "true" {
|
||||
require.Error(t, c.UpdateConfig("//non-existentpath\\", &newCfg, false), "UpdateConfig should error on non-existent path")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -173,8 +173,8 @@ var (
|
||||
|
||||
// Gateio is the overarching type across this package
|
||||
type Gateio struct {
|
||||
Counter common.Counter // Must be first due to alignment requirements
|
||||
exchange.Base
|
||||
Counter common.Counter
|
||||
}
|
||||
|
||||
// ***************************************** SubAccounts ********************************
|
||||
|
||||
Reference in New Issue
Block a user