Files
gocryptotrader/backtester/config/batcktesterconfig_test.go
Adrian Gallagher 19b8957f3f codebase: Replace !errors.Is(err, target) with testify (#1931)
* 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
2025-06-10 16:29:57 +10:00

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)
}
}