Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enabled testifylint #1009

Merged
merged 4 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ linters:
- scopelint
- structcheck
- testableexamples
- testifylint
- testpackage
- thelper
- varnamelen
Expand Down
5 changes: 2 additions & 3 deletions internal/conn/error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ func TestNodeErrorIs(t *testing.T) {
testErr2 := errors.New("test2")
nodeErr := newConnError(1, "localhost:1234", testErr)

require.True(t, errors.Is(nodeErr, testErr))
require.False(t, errors.Is(nodeErr, testErr2))
require.ErrorIs(t, nodeErr, testErr)
require.NotErrorIs(t, nodeErr, testErr2)
}

type testErrorType1 struct {
Expand All @@ -53,7 +53,6 @@ func TestNodeErrorAs(t *testing.T) {
nodeErr := newConnError(1, "localhost:1234", testErr)

target := testErrorType1{}
require.True(t, errors.As(nodeErr, &target))
require.ErrorAs(t, nodeErr, &target)
require.Equal(t, testErr, target)

Expand Down
4 changes: 2 additions & 2 deletions internal/meta/trace_id_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestTraceID(t *testing.T) {
require.Equal(t, "00000000-0000-0000-0000-000000000000", id)
md, has := metadata.FromOutgoingContext(ctx)
require.True(t, has)
require.Equal(t, 1, len(md[HeaderTraceID]))
require.Len(t, md[HeaderTraceID], 1)
require.Equal(t, id, md[HeaderTraceID][0])
})
t.Run("TraceID from rand failed", func(t *testing.T) {
Expand All @@ -51,7 +51,7 @@ func TestTraceID(t *testing.T) {
require.Equal(t, "{test}", id)
md, has := metadata.FromOutgoingContext(ctx)
require.True(t, has)
require.Equal(t, 1, len(md[HeaderTraceID]))
require.Len(t, md[HeaderTraceID], 1)
require.Equal(t, id, md[HeaderTraceID][0])
})
}
4 changes: 2 additions & 2 deletions internal/table/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@ func TestDeadlockOnUpdateNodes(t *testing.T) {
require.NoError(t, err)
s3, err := c.Get(ctx)
require.NoError(t, err)
require.Equal(t, 3, len(nodes))
require.Len(t, nodes, 3)
err = c.Put(ctx, s1)
require.NoError(t, err)
err = c.Put(ctx, s2)
Expand Down Expand Up @@ -998,7 +998,7 @@ func TestDeadlockOnInternalPoolGCTick(t *testing.T) {
return
}
require.NoError(t, err)
require.Equal(t, 3, len(nodes))
require.Len(t, nodes, 3)
err = c.Put(ctx, s1)
if err != nil && errors.Is(err, context.DeadlineExceeded) {
return
Expand Down
2 changes: 1 addition & 1 deletion internal/table/scanner/result_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ func TestNewStreamWithRecvFirstResultSet(t *testing.T) {
}
err = result.NextResultSetErr(tt.ctx)
require.ErrorIs(t, err, io.EOF)
require.True(t, err == io.EOF) //nolint:errorlint
require.True(t, err == io.EOF) //nolint:errorlint,testifylint
require.Equal(t, 1001, tt.recvCounter)
require.Equal(t, 1002, int(result.(*streamResult).nextResultSetCounter.Load()))
}
Expand Down
3 changes: 1 addition & 2 deletions internal/topic/topicreaderinternal/reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"runtime"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.uber.org/mock/gomock"

Expand Down Expand Up @@ -168,5 +167,5 @@ func TestReader_WaitInit(t *testing.T) {

baseReader.EXPECT().WaitInit(gomock.Any())
err := reader.WaitInit(context.Background())
assert.NoError(t, err)
require.NoError(t, err)
}
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ func TestSplitMessagesByBufCodec(t *testing.T) {
for _, group := range groups {
require.NotEmpty(t, group)
require.True(t, allMessagesHasSameBufCodec(group))
require.Equal(t, len(group), cap(group))
require.Len(t, group, cap(group))
for _, mess := range group {
expectedNum++
require.Equal(t, test[int(expectedNum)], mess.bufCodec)
Expand Down
2 changes: 1 addition & 1 deletion internal/xerrors/transport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func TestTransportErrorName(t *testing.T) {
} {
t.Run("", func(t *testing.T) {
if tt.err == nil {
require.Nil(t, TransportError(tt.err))
require.Nil(t, TransportError(tt.err)) //nolint:testifylint
} else {
require.Equal(t, tt.name, TransportError(tt.err).Name())
}
Expand Down
2 changes: 1 addition & 1 deletion internal/xsync/event_broadcast_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,6 @@ func TestEventBroadcast(t *testing.T) {
stopBroadcast.Store(true)
<-broadcastStopped

require.True(t, events.Load() > 0)
require.Greater(t, events.Load(), int64(0))
})
}
2 changes: 1 addition & 1 deletion log/logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

func TestColoring(t *testing.T) {
zeroClock := clockwork.NewFakeClock()
fullDuration := zeroClock.Now().Sub(time.Date(1984, 4, 4, 0, 0, 0, 0, time.Local))
fullDuration := zeroClock.Now().Sub(time.Date(1984, 4, 4, 0, 0, 0, 0, time.UTC))
zeroClock.Advance(-fullDuration) // set zero time
for _, tt := range []struct {
l *defaultLogger
Expand Down
2 changes: 1 addition & 1 deletion table/options/models_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func TestTimeToLiveSettingsFluentModifiers(t *testing.T) {
},
} {
t.Run("", func(t *testing.T) {
require.Equal(t, tt.fluentSettings, tt.expectedSettings)
require.Equal(t, tt.expectedSettings, tt.fluentSettings)
})
}
}
2 changes: 1 addition & 1 deletion table/options/options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ func TestSessionOptionsProfile(t *testing.T) {
} else {
require.Equal(
t,
p.PartitionAtKeys.SplitPoints,
[]*Ydb.TypedValue{value.ToYDB(types.Int64Value(1), a)},
p.PartitionAtKeys.SplitPoints,
)
}
}
Expand Down
Loading