mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 15:09:42 +00:00
Config: Add versioning (#1671)
* 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
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/thrasher-corp/gocryptotrader/config"
|
||||
)
|
||||
|
||||
@@ -269,9 +270,16 @@ func TestConfigAllJsonResponse(t *testing.T) {
|
||||
var responseConfig config.Config
|
||||
err = json.Unmarshal(body, &responseConfig)
|
||||
assert.NoError(t, err, "Unmarshal should not error")
|
||||
for _, e := range responseConfig.Exchanges {
|
||||
for i, e := range responseConfig.Exchanges {
|
||||
err = e.CurrencyPairs.SetDelimitersFromConfig()
|
||||
assert.NoError(t, err, "SetDelimitersFromConfig should not error")
|
||||
// Using require here makes it much easier to isolate differences per-exchange than below
|
||||
// We look into pointers separately
|
||||
for a, p := range e.CurrencyPairs.Pairs {
|
||||
require.Equalf(t, c.Exchanges[i].CurrencyPairs.Pairs[a], p, "%s exchange Config CurrencyManager Pairs for asset %s must match api response", e.Name, a)
|
||||
}
|
||||
require.Equalf(t, c.Exchanges[i].CurrencyPairs, e.CurrencyPairs, "%s exchange Config CurrencyManager must match api response", e.Name)
|
||||
require.Equalf(t, c.Exchanges[i], e, "%s exchange Config must match api response", e.Name) // require here makes it much easier to isolate differences than below
|
||||
}
|
||||
assert.Equal(t, c, responseConfig, "Config should match api response")
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ func loadConfigWithSettings(settings *Settings, flagSet map[string]bool) (*confi
|
||||
conf := &config.Config{}
|
||||
err = conf.ReadConfigFromFile(filePath, settings.EnableDryRun)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf(config.ErrFailureOpeningConfig, filePath, err)
|
||||
return nil, fmt.Errorf("%w %s: %w", config.ErrFailureOpeningConfig, filePath, err)
|
||||
}
|
||||
// Apply overrides from settings
|
||||
if flagSet["datadir"] {
|
||||
|
||||
Reference in New Issue
Block a user