diff --git a/.golangci.yml b/.golangci.yml index 379c2f6a..344d9962 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -21,8 +21,16 @@ linters: - prealloc - predeclared - reassign + - testifylint linters-settings: staticcheck: checks: - all - '-SA1024' + testifylint: + disable-all: true + enable: + - compares + - empty + - expected-actual + - len diff --git a/pkg/fixtures/test/expecter_test.go b/pkg/fixtures/test/expecter_test.go index 42339862..f61424c8 100644 --- a/pkg/fixtures/test/expecter_test.go +++ b/pkg/fixtures/test/expecter_test.go @@ -117,7 +117,7 @@ func TestExpecter(t *testing.T) { require.NoError(t, expMock.Variadic(1, 2, 3, 4)) require.NoError(t, expMock.Variadic(2, 3, 4)) require.NoError(t, expMock.Variadic(args...)) - require.Equal(t, runCalled, 5) + require.Equal(t, 5, runCalled) expMock.AssertExpectations(t) }) @@ -175,7 +175,7 @@ func TestExpecter(t *testing.T) { }).Return(nil).Once() require.NoError(t, expMock.VariadicMany(defaultInt, defaultString, args...)) - require.Equal(t, runCalled, 5) + require.Equal(t, 5, runCalled) expMock.AssertExpectations(t) }) diff --git a/pkg/parse_test.go b/pkg/parse_test.go index 4d714cdb..ff313078 100644 --- a/pkg/parse_test.go +++ b/pkg/parse_test.go @@ -42,7 +42,7 @@ func TestBuildTagInFilename(t *testing.T) { assert.NoError(t, err) // Expect "redeclared in this block" if tags aren't respected nodes := parser.Interfaces() - assert.Equal(t, 1, len(nodes)) + require.Len(t, nodes, 1) assert.Equal(t, "IfaceWithBuildTagInFilename", nodes[0].Name) } @@ -64,7 +64,7 @@ func TestBuildTagInComment(t *testing.T) { assert.NoError(t, err) // Expect "redeclared in this block" if tags aren't respected nodes := parser.Interfaces() - assert.Equal(t, 1, len(nodes)) + require.Len(t, nodes, 1) assert.Equal(t, "IfaceWithBuildTagInComment", nodes[0].Name) } @@ -94,6 +94,5 @@ func TestCustomBuildTag(t *testing.T) { func TestParsePackages(t *testing.T) { parser := NewParser([]string{}) require.NoError(t, parser.ParsePackages(context.Background(), []string{"github.com/vektra/mockery/v2/pkg/fixtures"})) - assert.NotEqual(t, 0, len(parser.files)) - + assert.NotEmpty(t, parser.files) } diff --git a/pkg/walker_test.go b/pkg/walker_test.go index 0fdfc3e9..90431f04 100644 --- a/pkg/walker_test.go +++ b/pkg/walker_test.go @@ -63,7 +63,7 @@ func TestWalkerHere(t *testing.T) { w.Walk(context.Background(), gv) - assert.True(t, len(gv.Interfaces) > 10) + assert.Greater(t, len(gv.Interfaces), 10) first := gv.Interfaces[0] assert.Equal(t, "A", first.Name) assert.Equal(t, getFixturePath("struct_value.go"), first.FileName) @@ -88,7 +88,7 @@ func TestWalkerRegexp(t *testing.T) { w.Walk(context.Background(), gv) - assert.True(t, len(gv.Interfaces) >= 1) + assert.GreaterOrEqual(t, len(gv.Interfaces), 1) first := gv.Interfaces[0] assert.Equal(t, "AsyncProducer", first.Name) assert.Equal(t, getFixturePath("async.go"), first.FileName)