mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 15:09:42 +00:00
Config: fix don't create empty dir when resolving path (#575)
* Config: fix don't create empty dir when resolving path * refactor migration of default config file * gracefully handle src == target on Move * create target directory on Move, if necessary * unify resolution of default config location * refactor the use of flagSet to be explicit * remove package variable * use empty config file path setting if not set in flags * resolve default file location the same way when showing the target and when loading default config file * don't migrate if target file is the same as source * rename configfile to configFile * add migrateConfig tests
This commit is contained in:
@@ -51,12 +51,12 @@ func TestLoadConfigWithSettings(t *testing.T) {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
// prepare the 'flags'
|
||||
flagSet = make(map[string]bool)
|
||||
flagSet := make(map[string]bool)
|
||||
for _, v := range tt.flags {
|
||||
flagSet[v] = true
|
||||
}
|
||||
// Run the test
|
||||
got, err := loadConfigWithSettings(tt.settings)
|
||||
got, err := loadConfigWithSettings(tt.settings, flagSet)
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Errorf("loadConfigWithSettings() error = %v, wantErr %v", err, tt.wantErr)
|
||||
return
|
||||
@@ -77,7 +77,7 @@ func TestStartStopDoesNotCausePanic(t *testing.T) {
|
||||
botOne, err := NewFromSettings(&Settings{
|
||||
ConfigFile: config.TestFile,
|
||||
EnableDryRun: true,
|
||||
})
|
||||
}, make(map[string]bool))
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user