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:
parent
03b868402c
commit
fd8c110293
|
@ -16,6 +16,7 @@ import (
|
||||||
"github.com/status-im/status-go/geth/params"
|
"github.com/status-im/status-go/geth/params"
|
||||||
assertions "github.com/stretchr/testify/require"
|
assertions "github.com/stretchr/testify/require"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -144,12 +145,19 @@ func MakeTestNodeConfig(networkID int) (*params.NodeConfig, error) {
|
||||||
testDir = filepath.ToSlash(testDir)
|
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 := `{
|
configJSON := `{
|
||||||
"NetworkId": ` + strconv.Itoa(networkID) + `,
|
"NetworkId": ` + strconv.Itoa(networkID) + `,
|
||||||
"DataDir": "` + testDir + `",
|
"DataDir": "` + testDir + `",
|
||||||
"HTTPPort": ` + strconv.Itoa(TestConfig.Node.HTTPPort) + `,
|
"HTTPPort": ` + strconv.Itoa(TestConfig.Node.HTTPPort) + `,
|
||||||
"WSPort": ` + strconv.Itoa(TestConfig.Node.WSPort) + `,
|
"WSPort": ` + strconv.Itoa(TestConfig.Node.WSPort) + `,
|
||||||
"LogLevel": "INFO"
|
"LogLevel": "` + errorLevel + `"
|
||||||
}`
|
}`
|
||||||
|
|
||||||
nodeConfig, err := params.LoadNodeConfig(configJSON)
|
nodeConfig, err := params.LoadNodeConfig(configJSON)
|
||||||
|
|
Loading…
Reference in New Issue