bbgo_origin/pkg/config/loader_test.go

51 lines
842 B
Go
Raw Normal View History

2020-10-20 06:32:22 +00:00
package config
2020-10-20 05:52:25 +00:00
import (
"testing"
"github.com/stretchr/testify/assert"
// register the strategies
_ "github.com/c9s/bbgo/pkg/strategy/buyandhold"
)
2020-10-23 06:01:45 +00:00
func TestLoadConfig(t *testing.T) {
2020-10-20 05:52:25 +00:00
type args struct {
configFile string
}
tests := []struct {
name string
args args
wantErr bool
length int
}{
{
name: "simple",
args: args{
configFile: "testdata/strategy.yaml",
},
wantErr: false,
length: 1,
},
}
2020-10-20 06:14:21 +00:00
2020-10-20 05:52:25 +00:00
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
2020-10-20 06:32:22 +00:00
config, err := Load(tt.args.configFile)
2020-10-20 05:52:25 +00:00
if err != nil {
2020-10-20 06:32:22 +00:00
t.Errorf("Load() error = %v", err)
return
2020-10-20 05:52:25 +00:00
} else {
if tt.wantErr {
2020-10-20 06:32:22 +00:00
t.Errorf("Load() error = %v, wantErr %v", err, tt.wantErr)
return
2020-10-20 05:52:25 +00:00
}
}
2020-10-20 06:32:22 +00:00
assert.NotNil(t, config)
assert.Len(t, config.ExchangeStrategies, tt.length)
2020-10-20 05:52:25 +00:00
})
}
}