mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-01 23:16:51 +00:00
Config: refactor config file loaders (#577)
* Config: fix don't create empty dir when resolving path * Config: refactor config file loaders * add a layer of abstraction so that config can be loaded from non-files * use io.Reader / io.Writer abstraction to separate data operations from file operations * remove dryrun option from SaveConfig - now it always saves * rename read and save methods to mention file operations * log error when encryption prompt fails * as the user didn't make a choice, we'd prompt again next time the file is loaded * add file.Writer tests * skip permissions test for windows * defer creating the writer on save to the last moment * this avoids truncating file when there is error with password prompt * add a test * tests with StdIn cannot run in parallel
This commit is contained in:
@@ -227,7 +227,7 @@ func makeExchange(exch *exchange) error {
|
||||
}
|
||||
|
||||
configTestFile.Exchanges = append(configTestFile.Exchanges, newExchConfig)
|
||||
err = configTestFile.SaveConfig(exchangeConfigPath, false)
|
||||
err = configTestFile.SaveConfigToFile(exchangeConfigPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ func TestNewExchange(t *testing.T) {
|
||||
t.Fatalf("unable to remove exchange config for %s, manual removal required\n",
|
||||
testExchangeName)
|
||||
}
|
||||
if err := cfg.SaveConfig(exchangeConfigPath, false); err != nil {
|
||||
if err := cfg.SaveConfigToFile(exchangeConfigPath); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user