Files
gocryptotrader/backtester/config/btcktesterconfig_test.go
Scott 1461cba363 backtester: standalone application (#988)
* Ramshackle early leads to GRPC backtester

* Adds GRPC server, default config generation

* Partial support for GRPC backtester config

* Update to use Buf, merge fixes

* Full config for GRPC

* Adds new commands, causes big panic

* Fixes panics

* Setup for the future

* Docs update

* test

* grpc tests

* Fix merge issues. Lint and test

* minor fixes after rebase

* Docs, formatting and main fixes

* Change buf owner

* shazNits

* test-123

* rpc fixes

* string fixes

* Removes --singlerun flag and just relies on --singlerunstrategypath

* fixes test

* initial post merge compatability fixes

* this actually all seems to work? unexpected

* adds pluginpath to config

* rm unused func. add gitignore

* rm unused func. add gitignore

* lintle

* tITLE cASE lOG fIX,rm auth package, gitignore, tmpdir fix

* buf updates + gen. go mod tidy

* x2

* Update default port, update error text
2022-09-08 16:22:30 +10:00

50 lines
1003 B
Go

package config
import (
"encoding/json"
"errors"
"path/filepath"
"testing"
"github.com/thrasher-corp/gocryptotrader/backtester/common"
"github.com/thrasher-corp/gocryptotrader/common/file"
)
func TestLoadBacktesterConfig(t *testing.T) {
t.Parallel()
cfg, err := GenerateDefaultConfig()
if err != nil {
t.Error(err)
}
testConfig, err := json.Marshal(cfg)
if err != nil {
t.Error(err)
}
dir := t.TempDir()
f := filepath.Join(dir, "test.config")
err = file.Write(f, testConfig)
if err != nil {
t.Error(err)
}
_, err = ReadBacktesterConfigFromPath(f)
if err != nil {
t.Error(err)
}
_, err = ReadBacktesterConfigFromPath("test")
if !errors.Is(err, common.ErrFileNotFound) {
t.Errorf("received '%v' expected '%v'", err, common.ErrFileNotFound)
}
}
func TestGenerateDefaultConfig(t *testing.T) {
t.Parallel()
cfg, err := GenerateDefaultConfig()
if err != nil {
t.Error(err)
}
if !cfg.PrintLogo {
t.Errorf("received '%v' expected '%v'", cfg.PrintLogo, true)
}
}