mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-22 15:10:13 +00:00
* Config: Version Management * Engine: Improve visibility of TestConfigAllJsonResponse failures * Config: Update cmd/config to allow upgrades * Config: Add Version2 to rename GDAX * Config: Restructure versioning to share types This restructure allows us to share types between versions, avoids needing to import the versions, and puts the test fixtures in same package. It's a win on all fronts * Config: Fix SetNTPCheck using log Called from engine before logger is inited, and also just wrong to use log to communicate with user * Config: Improve TestMigrateConfig * Config: Drop requirement for versions to be registered in sequence Checking the versions at Deploy is much saner. * Config: Fix file encrypted but flag not set * Config: Add -edit and encryption upgrade to cmd/config This simplifies the handling for encryption prompts by moving it to a field on config, allowing us to simplify all the places were were passing around config Also moves password entry to being secure (echo-off) * Tests: Fix inconsistent should/must assertions
38 lines
963 B
Go
38 lines
963 B
Go
package versions
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestVersion2Upgrade(t *testing.T) {
|
|
t.Parallel()
|
|
for _, tt := range [][]string{
|
|
{"GDAX", "CoinbasePro"},
|
|
{"Kraken", "Kraken"},
|
|
{"CoinbasePro", "CoinbasePro"},
|
|
} {
|
|
out, err := new(Version2).UpgradeExchange(context.Background(), []byte(`{"name":"`+tt[0]+`"}`))
|
|
require.NoError(t, err)
|
|
require.NotEmpty(t, out)
|
|
assert.Equalf(t, `{"name":"`+tt[1]+`"}`, string(out), "Test exchange name %s", tt[0])
|
|
}
|
|
}
|
|
|
|
func TestVersion2Downgrade(t *testing.T) {
|
|
t.Parallel()
|
|
for _, tt := range [][]string{
|
|
{"GDAX", "GDAX"},
|
|
{"Kraken", "Kraken"},
|
|
{"CoinbasePro", "GDAX"},
|
|
} {
|
|
out, err := new(Version2).DowngradeExchange(context.Background(), []byte(`{"name":"`+tt[0]+`"}`))
|
|
require.NoError(t, err)
|
|
require.NotEmpty(t, out)
|
|
assert.Equalf(t, `{"name":"`+tt[1]+`"}`, string(out), "Test exchange name %s", tt[0])
|
|
}
|
|
}
|