testing: pass testing.T to assert and require always, assertion cleanup (#7508)

This commit is contained in:
Sam Kleinman
2022-01-05 09:25:08 -05:00
committed by GitHub
parent 3c8955e4b8
commit f2cc496f09
46 changed files with 381 additions and 417 deletions
+5 -5
View File
@@ -74,7 +74,7 @@ func TestRootHome(t *testing.T) {
idxString := strconv.Itoa(i)
err := testSetup(defaultRoot, tc.args, tc.env)
require.Nil(t, err, idxString)
require.NoError(t, err, idxString)
assert.Equal(t, tc.root, config.RootDir, idxString)
assert.Equal(t, tc.root, config.P2P.RootDir, idxString)
@@ -106,7 +106,7 @@ func TestRootFlagsEnv(t *testing.T) {
idxString := strconv.Itoa(i)
err := testSetup(defaultRoot, tc.args, tc.env)
require.Nil(t, err, idxString)
require.NoError(t, err, idxString)
assert.Equal(t, tc.logLevel, config.LogLevel, idxString)
}
@@ -139,12 +139,12 @@ func TestRootConfig(t *testing.T) {
// XXX: path must match cfg.defaultConfigPath
configFilePath := filepath.Join(defaultRoot, "config")
err := tmos.EnsureDir(configFilePath, 0700)
require.Nil(t, err)
require.NoError(t, err)
// write the non-defaults to a different path
// TODO: support writing sub configs so we can test that too
err = WriteConfigVals(configFilePath, cvals)
require.Nil(t, err)
require.NoError(t, err)
rootCmd := testRootCmd()
cmd := cli.PrepareBaseCmd(rootCmd, "TM", defaultRoot)
@@ -152,7 +152,7 @@ func TestRootConfig(t *testing.T) {
// run with the args and env
tc.args = append([]string{rootCmd.Use}, tc.args...)
err = cli.RunWithArgs(cmd, tc.args, tc.env)
require.Nil(t, err, idxString)
require.NoError(t, err, idxString)
assert.Equal(t, tc.logLvl, config.LogLevel, idxString)
}