Add support for 'go test -v' flag for tests (#315)

Default log level for tests is now ERROR. If tests are invoked with -v, the log level becomes INFO.
This commit is contained in:
Ivan Daniluk 2017-09-14 13:41:50 +02:00 committed by Ivan Tomilov
parent 03b868402c
commit fd8c110293
1 changed files with 9 additions and 1 deletions

View File

@ -16,6 +16,7 @@ import (
"github.com/status-im/status-go/geth/params"
assertions "github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
"testing"
)
var (
@ -144,12 +145,19 @@ func MakeTestNodeConfig(networkID int) (*params.NodeConfig, error) {
testDir = filepath.ToSlash(testDir)
}
// run tests with "INFO" log level only
// when `go test` invoked with `-v` flag
errorLevel := "ERROR"
if testing.Verbose() {
errorLevel = "INFO"
}
configJSON := `{
"NetworkId": ` + strconv.Itoa(networkID) + `,
"DataDir": "` + testDir + `",
"HTTPPort": ` + strconv.Itoa(TestConfig.Node.HTTPPort) + `,
"WSPort": ` + strconv.Itoa(TestConfig.Node.WSPort) + `,
"LogLevel": "INFO"
"LogLevel": "` + errorLevel + `"
}`
nodeConfig, err := params.LoadNodeConfig(configJSON)