fix metalinter errors
This commit is contained in:
parent
668698584d
commit
d8dd497069
|
@ -37,11 +37,10 @@ func destroyTestGroup(t *testing.T, g *Group) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func assertGroupInfo(t *testing.T, gInfo GroupInfo, minIndex, maxIndex int, totalSize, headSize int64) {
|
func assertGroupInfo(t *testing.T, gInfo GroupInfo, minIndex, maxIndex int, totalSize, headSize int64) {
|
||||||
assert := assert.New(t)
|
assert.Equal(t, minIndex, gInfo.MinIndex)
|
||||||
assert.Equal(minIndex, gInfo.MinIndex)
|
assert.Equal(t, maxIndex, gInfo.MaxIndex)
|
||||||
assert.Equal(maxIndex, gInfo.MaxIndex)
|
assert.Equal(t, totalSize, gInfo.TotalSize)
|
||||||
assert.Equal(totalSize, gInfo.TotalSize)
|
assert.Equal(t, headSize, gInfo.HeadSize)
|
||||||
assert.Equal(headSize, gInfo.HeadSize)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCheckHeadSizeLimit(t *testing.T) {
|
func TestCheckHeadSizeLimit(t *testing.T) {
|
||||||
|
|
|
@ -14,8 +14,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSetupEnv(t *testing.T) {
|
func TestSetupEnv(t *testing.T) {
|
||||||
assert, require := assert.New(t), require.New(t)
|
|
||||||
|
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
args []string
|
args []string
|
||||||
env map[string]string
|
env map[string]string
|
||||||
|
@ -51,22 +49,20 @@ func TestSetupEnv(t *testing.T) {
|
||||||
viper.Reset()
|
viper.Reset()
|
||||||
args := append([]string{cmd.Use}, tc.args...)
|
args := append([]string{cmd.Use}, tc.args...)
|
||||||
err := RunWithArgs(cmd, args, tc.env)
|
err := RunWithArgs(cmd, args, tc.env)
|
||||||
require.Nil(err, i)
|
require.Nil(t, err, i)
|
||||||
assert.Equal(tc.expected, foo, i)
|
assert.Equal(t, tc.expected, foo, i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSetupConfig(t *testing.T) {
|
func TestSetupConfig(t *testing.T) {
|
||||||
assert, require := assert.New(t), require.New(t)
|
|
||||||
|
|
||||||
// we pre-create two config files we can refer to in the rest of
|
// we pre-create two config files we can refer to in the rest of
|
||||||
// the test cases.
|
// the test cases.
|
||||||
cval1, cval2 := "fubble", "wubble"
|
cval1, cval2 := "fubble", "wubble"
|
||||||
conf1, err := WriteDemoConfig(map[string]string{"boo": cval1})
|
conf1, err := WriteDemoConfig(map[string]string{"boo": cval1})
|
||||||
require.Nil(err)
|
require.Nil(t, err)
|
||||||
// make sure it handles dashed-words in the config, and ignores random info
|
// make sure it handles dashed-words in the config, and ignores random info
|
||||||
conf2, err := WriteDemoConfig(map[string]string{"boo": cval2, "foo": "bar", "two-words": "WORD"})
|
conf2, err := WriteDemoConfig(map[string]string{"boo": cval2, "foo": "bar", "two-words": "WORD"})
|
||||||
require.Nil(err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
args []string
|
args []string
|
||||||
|
@ -110,9 +106,9 @@ func TestSetupConfig(t *testing.T) {
|
||||||
viper.Reset()
|
viper.Reset()
|
||||||
args := append([]string{cmd.Use}, tc.args...)
|
args := append([]string{cmd.Use}, tc.args...)
|
||||||
err := RunWithArgs(cmd, args, tc.env)
|
err := RunWithArgs(cmd, args, tc.env)
|
||||||
require.Nil(err, i)
|
require.Nil(t, err, i)
|
||||||
assert.Equal(tc.expected, foo, i)
|
assert.Equal(t, tc.expected, foo, i)
|
||||||
assert.Equal(tc.expectedTwo, two, i)
|
assert.Equal(t, tc.expectedTwo, two, i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,16 +119,14 @@ type DemoConfig struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSetupUnmarshal(t *testing.T) {
|
func TestSetupUnmarshal(t *testing.T) {
|
||||||
assert, require := assert.New(t), require.New(t)
|
|
||||||
|
|
||||||
// we pre-create two config files we can refer to in the rest of
|
// we pre-create two config files we can refer to in the rest of
|
||||||
// the test cases.
|
// the test cases.
|
||||||
cval1, cval2 := "someone", "else"
|
cval1, cval2 := "someone", "else"
|
||||||
conf1, err := WriteDemoConfig(map[string]string{"name": cval1})
|
conf1, err := WriteDemoConfig(map[string]string{"name": cval1})
|
||||||
require.Nil(err)
|
require.Nil(t, err)
|
||||||
// even with some ignored fields, should be no problem
|
// even with some ignored fields, should be no problem
|
||||||
conf2, err := WriteDemoConfig(map[string]string{"name": cval2, "foo": "bar"})
|
conf2, err := WriteDemoConfig(map[string]string{"name": cval2, "foo": "bar"})
|
||||||
require.Nil(err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
// unused is not declared on a flag and remains from base
|
// unused is not declared on a flag and remains from base
|
||||||
base := DemoConfig{
|
base := DemoConfig{
|
||||||
|
@ -189,14 +183,12 @@ func TestSetupUnmarshal(t *testing.T) {
|
||||||
viper.Reset()
|
viper.Reset()
|
||||||
args := append([]string{cmd.Use}, tc.args...)
|
args := append([]string{cmd.Use}, tc.args...)
|
||||||
err := RunWithArgs(cmd, args, tc.env)
|
err := RunWithArgs(cmd, args, tc.env)
|
||||||
require.Nil(err, i)
|
require.Nil(t, err, i)
|
||||||
assert.Equal(tc.expected, cfg, i)
|
assert.Equal(t, tc.expected, cfg, i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSetupTrace(t *testing.T) {
|
func TestSetupTrace(t *testing.T) {
|
||||||
assert, require := assert.New(t), require.New(t)
|
|
||||||
|
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
args []string
|
args []string
|
||||||
env map[string]string
|
env map[string]string
|
||||||
|
@ -224,16 +216,16 @@ func TestSetupTrace(t *testing.T) {
|
||||||
viper.Reset()
|
viper.Reset()
|
||||||
args := append([]string{cmd.Use}, tc.args...)
|
args := append([]string{cmd.Use}, tc.args...)
|
||||||
stdout, stderr, err := RunCaptureWithArgs(cmd, args, tc.env)
|
stdout, stderr, err := RunCaptureWithArgs(cmd, args, tc.env)
|
||||||
require.NotNil(err, i)
|
require.NotNil(t, err, i)
|
||||||
require.Equal("", stdout, i)
|
require.Equal(t, "", stdout, i)
|
||||||
require.NotEqual("", stderr, i)
|
require.NotEqual(t, "", stderr, i)
|
||||||
msg := strings.Split(stderr, "\n")
|
msg := strings.Split(stderr, "\n")
|
||||||
desired := fmt.Sprintf("ERROR: %s", tc.expected)
|
desired := fmt.Sprintf("ERROR: %s", tc.expected)
|
||||||
assert.Equal(desired, msg[0], i)
|
assert.Equal(t, desired, msg[0], i)
|
||||||
if tc.long && assert.True(len(msg) > 2, i) {
|
if tc.long && assert.True(t, len(msg) > 2, i) {
|
||||||
// the next line starts the stack trace...
|
// the next line starts the stack trace...
|
||||||
assert.Contains(msg[1], "TestSetupTrace", i)
|
assert.Contains(t, msg[1], "TestSetupTrace", i)
|
||||||
assert.Contains(msg[2], "setup_test.go", i)
|
assert.Contains(t, msg[2], "setup_test.go", i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue