mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-04 07:26:47 +00:00
remove TestBypass flag (#566)
Tests should explicitly state their target configuration file, so no need to use fallback default override flag
This commit is contained in:
@@ -5,7 +5,6 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/thrasher-corp/gocryptotrader/config"
|
|
||||||
"github.com/thrasher-corp/gocryptotrader/core"
|
"github.com/thrasher-corp/gocryptotrader/core"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
)
|
)
|
||||||
@@ -36,7 +35,6 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestLoad(t *testing.T) {
|
func TestLoad(t *testing.T) {
|
||||||
config.TestBypass = true
|
|
||||||
fs := &flag.FlagSet{}
|
fs := &flag.FlagSet{}
|
||||||
fs.String("config", testConfig, "")
|
fs.String("config", testConfig, "")
|
||||||
newCtx := cli.NewContext(testApp, fs, &cli.Context{})
|
newCtx := cli.NewContext(testApp, fs, &cli.Context{})
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import (
|
|||||||
"bufio"
|
"bufio"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"flag"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
@@ -1484,10 +1483,6 @@ func GetFilePath(configfile string) (string, error) {
|
|||||||
return configfile, nil
|
return configfile, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if flag.Lookup("test.v") != nil && !TestBypass {
|
|
||||||
return TestFile, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
exePath, err := common.GetExecutablePath()
|
exePath, err := common.GetExecutablePath()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import (
|
|||||||
|
|
||||||
"github.com/thrasher-corp/gocryptotrader/common"
|
"github.com/thrasher-corp/gocryptotrader/common"
|
||||||
"github.com/thrasher-corp/gocryptotrader/common/convert"
|
"github.com/thrasher-corp/gocryptotrader/common/convert"
|
||||||
|
"github.com/thrasher-corp/gocryptotrader/common/file"
|
||||||
"github.com/thrasher-corp/gocryptotrader/connchecker"
|
"github.com/thrasher-corp/gocryptotrader/connchecker"
|
||||||
"github.com/thrasher-corp/gocryptotrader/currency"
|
"github.com/thrasher-corp/gocryptotrader/currency"
|
||||||
"github.com/thrasher-corp/gocryptotrader/database"
|
"github.com/thrasher-corp/gocryptotrader/database"
|
||||||
@@ -1643,11 +1644,6 @@ func TestReadConfig(t *testing.T) {
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
t.Error("TestReadConfig error cannot be nil")
|
t.Error("TestReadConfig error cannot be nil")
|
||||||
}
|
}
|
||||||
|
|
||||||
err = readConfig.ReadConfig("", true)
|
|
||||||
if err != nil {
|
|
||||||
t.Error("TestReadConfig error")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLoadConfig(t *testing.T) {
|
func TestLoadConfig(t *testing.T) {
|
||||||
@@ -1714,12 +1710,17 @@ func TestGetFilePath(t *testing.T) {
|
|||||||
t.Errorf("TestGetFilePath: expected %s got %s", expected, result)
|
t.Errorf("TestGetFilePath: expected %s got %s", expected, result)
|
||||||
}
|
}
|
||||||
|
|
||||||
expected = TestFile
|
expected = DefaultFilePath()
|
||||||
result, _ = GetFilePath("")
|
result, err := GetFilePath("")
|
||||||
if result != expected {
|
if file.Exists(expected) {
|
||||||
t.Errorf("TestGetFilePath: expected %s got %s", expected, result)
|
if err != nil || result != expected {
|
||||||
|
t.Errorf("TestGetFilePath: expected %s got %s", expected, result)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if err == nil {
|
||||||
|
t.Error("Expected error when default config file does not exist")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
TestBypass = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCheckRemoteControlConfig(t *testing.T) {
|
func TestCheckRemoteControlConfig(t *testing.T) {
|
||||||
|
|||||||
@@ -69,7 +69,6 @@ const (
|
|||||||
var (
|
var (
|
||||||
Cfg Config
|
Cfg Config
|
||||||
IsInitialSetup bool
|
IsInitialSetup bool
|
||||||
TestBypass bool
|
|
||||||
m sync.Mutex
|
m sync.Mutex
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user