Skip to content

Commit

Permalink
remove TestBypass flag (thrasher-corp#566)
Browse files Browse the repository at this point in the history
Tests should explicitly state their target configuration file, so no need
to use fallback default override flag
  • Loading branch information
Rots authored Sep 27, 2020
1 parent d9bcf82 commit ecbc685
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 18 deletions.
2 changes: 0 additions & 2 deletions cmd/dbseed/dbseed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"path/filepath"
"testing"

"github.com/thrasher-corp/gocryptotrader/config"
"github.com/thrasher-corp/gocryptotrader/core"
"github.com/urfave/cli/v2"
)
Expand Down Expand Up @@ -36,7 +35,6 @@ var (
)

func TestLoad(t *testing.T) {
config.TestBypass = true
fs := &flag.FlagSet{}
fs.String("config", testConfig, "")
newCtx := cli.NewContext(testApp, fs, &cli.Context{})
Expand Down
5 changes: 0 additions & 5 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bufio"
"encoding/json"
"errors"
"flag"
"fmt"
"io"
"io/ioutil"
Expand Down Expand Up @@ -1484,10 +1483,6 @@ func GetFilePath(configfile string) (string, error) {
return configfile, nil
}

if flag.Lookup("test.v") != nil && !TestBypass {
return TestFile, nil
}

exePath, err := common.GetExecutablePath()
if err != nil {
return "", err
Expand Down
21 changes: 11 additions & 10 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/thrasher-corp/gocryptotrader/common"
"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/currency"
"github.com/thrasher-corp/gocryptotrader/database"
Expand Down Expand Up @@ -1643,11 +1644,6 @@ func TestReadConfig(t *testing.T) {
if err == nil {
t.Error("TestReadConfig error cannot be nil")
}

err = readConfig.ReadConfig("", true)
if err != nil {
t.Error("TestReadConfig error")
}
}

func TestLoadConfig(t *testing.T) {
Expand Down Expand Up @@ -1714,12 +1710,17 @@ func TestGetFilePath(t *testing.T) {
t.Errorf("TestGetFilePath: expected %s got %s", expected, result)
}

expected = TestFile
result, _ = GetFilePath("")
if result != expected {
t.Errorf("TestGetFilePath: expected %s got %s", expected, result)
expected = DefaultFilePath()
result, err := GetFilePath("")
if file.Exists(expected) {
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) {
Expand Down
1 change: 0 additions & 1 deletion config/config_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ const (
var (
Cfg Config
IsInitialSetup bool
TestBypass bool
m sync.Mutex
)

Expand Down

0 comments on commit ecbc685

Please sign in to comment.