mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-06 23:16:53 +00:00
* tests: Replace !errors.Is(err, target) with testify equivalents * codebase: Manual !errors.Is(err, target) replacements * typo: Replace errMisMatchedEvent with errMismatchedEvent * tests: Enhance error messages for better output * tests: Refactor error assertions in various test cases to use require and improve clarity * misc linter: Fix assert should wording * tests: Simplify assertions in TestCreateSignals for clarity and conciseness * tests: Enhance assertion message in TestCreateSignals
48 lines
999 B
Go
48 lines
999 B
Go
package config
|
|
|
|
import (
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/thrasher-corp/gocryptotrader/backtester/common"
|
|
"github.com/thrasher-corp/gocryptotrader/common/file"
|
|
"github.com/thrasher-corp/gocryptotrader/encoding/json"
|
|
)
|
|
|
|
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")
|
|
assert.ErrorIs(t, 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)
|
|
}
|
|
}
|