diff --git a/Makefile b/Makefile index 1b34d740..f2ffe814 100644 --- a/Makefile +++ b/Makefile @@ -37,7 +37,8 @@ lint: golangci-lint version golangci-lint run -E bidichk,durationcheck,errname,exportloopref \ -E forcetypeassert,godot,goerr113,gofumpt,gosec,nlreturn,prealloc \ - -E protogetter,unconvert,unparam,usestdlibvars --exclude-use-default=false + -E protogetter,testifylint,unconvert,unparam,usestdlibvars \ + --exclude-use-default=false go install golang.org/x/vuln/cmd/govulncheck@latest govulncheck -test ./... diff --git a/internal/hermes-api/service/identity_test.go b/internal/hermes-api/service/identity_test.go index 34f1f068..9865ac7a 100644 --- a/internal/hermes-api/service/identity_test.go +++ b/internal/hermes-api/service/identity_test.go @@ -247,8 +247,8 @@ func TestCreateIdentity(t *testing.T) { identityer.EXPECT().Create(gomock.Any(), identity).Return(retIdentity, otp, true, nil).Times(1) apper := NewMockApper(ctrl) - apper.EXPECT().Read(gomock.Any(), app.GetId(), app.GetOrgId()).Return(app, nil). - Times(1) + apper.EXPECT().Read(gomock.Any(), app.GetId(), app.GetOrgId()). + Return(app, nil).Times(1) eventer := NewMockEventer(ctrl) eventer.EXPECT().Create(gomock.Any(), event).Return(dao.ErrNotFound). Times(1) @@ -494,8 +494,8 @@ func TestCreateIdentity(t *testing.T) { uuid.NewString()) notifier := notify.NewMockNotifier(gomock.NewController(t)) - notifier.EXPECT().ValidateSMS(gomock.Any(), - identity.GetSmsMethod().GetPhone()).Return(notify.ErrInvalidSMS).Times(1) + notifier.EXPECT().ValidateSMS(gomock.Any(), identity.GetSmsMethod(). + GetPhone()).Return(notify.ErrInvalidSMS).Times(1) ctx, cancel := context.WithTimeout(session.NewContext( context.Background(), &session.Session{ @@ -521,7 +521,8 @@ func TestCreateIdentity(t *testing.T) { uuid.NewString()) notifier := notify.NewMockNotifier(gomock.NewController(t)) - notifier.EXPECT().ValidatePushover(identity.GetPushoverMethod().GetPushoverKey()).Return(notify.ErrInvalidPushover).Times(1) + notifier.EXPECT().ValidatePushover(identity.GetPushoverMethod(). + GetPushoverKey()).Return(notify.ErrInvalidPushover).Times(1) ctx, cancel := context.WithTimeout(session.NewContext( context.Background(), &session.Session{ diff --git a/internal/hermes-api/test/app_test.go b/internal/hermes-api/test/app_test.go index 08d2e9d0..82388dac 100644 --- a/internal/hermes-api/test/app_test.go +++ b/internal/hermes-api/test/app_test.go @@ -546,7 +546,7 @@ func TestListApps(t *testing.T) { }) t.Logf("nextApps, err: %+v, %v", nextApps, err) require.NoError(t, err) - require.GreaterOrEqual(t, len(nextApps.GetApps()), 1) + require.NotEmpty(t, nextApps.GetApps()) require.GreaterOrEqual(t, nextApps.GetTotalSize(), int32(3)) }) @@ -560,7 +560,7 @@ func TestListApps(t *testing.T) { listApps, err := secCli.ListApps(ctx, &api.ListAppsRequest{}) t.Logf("listApps, err: %+v, %v", listApps, err) require.NoError(t, err) - require.Len(t, listApps.GetApps(), 0) + require.Empty(t, listApps.GetApps()) require.Equal(t, int32(0), listApps.GetTotalSize()) }) diff --git a/internal/hermes-api/test/event_test.go b/internal/hermes-api/test/event_test.go index 85b9b4a4..51a7aadc 100644 --- a/internal/hermes-api/test/event_test.go +++ b/internal/hermes-api/test/event_test.go @@ -124,7 +124,7 @@ func TestListEvents(t *testing.T) { }) t.Logf("listEvents, err: %+v, %v", listEvents, err) require.NoError(t, err) - require.Len(t, listEvents.GetEvents(), 0) + require.Empty(t, listEvents.GetEvents()) }) t.Run("List events by invalid time range", func(t *testing.T) { @@ -283,7 +283,7 @@ func TestLatestEvents(t *testing.T) { latEvents, err := evCli.LatestEvents(ctx, &api.LatestEventsRequest{}) t.Logf("latEvents, err: %+v, %v", latEvents, err) require.NoError(t, err) - require.Len(t, latEvents.GetEvents(), 0) + require.Empty(t, latEvents.GetEvents()) }) t.Run("Latest events by invalid identity ID", func(t *testing.T) { diff --git a/internal/hermes-api/test/identity_test.go b/internal/hermes-api/test/identity_test.go index b8c0d513..0a44e281 100644 --- a/internal/hermes-api/test/identity_test.go +++ b/internal/hermes-api/test/identity_test.go @@ -1841,7 +1841,7 @@ func TestListIdentities(t *testing.T) { }) t.Logf("nextIdentities, err: %+v, %v", nextIdentities, err) require.NoError(t, err) - require.GreaterOrEqual(t, len(nextIdentities.GetIdentities()), 1) + require.NotEmpty(t, nextIdentities.GetIdentities()) require.GreaterOrEqual(t, nextIdentities.GetTotalSize(), int32(3)) }) @@ -1880,7 +1880,7 @@ func TestListIdentities(t *testing.T) { &api.ListIdentitiesRequest{}) t.Logf("listIdentities, err: %+v, %v", listIdentities, err) require.NoError(t, err) - require.Len(t, listIdentities.GetIdentities(), 0) + require.Empty(t, listIdentities.GetIdentities()) require.Equal(t, int32(0), listIdentities.GetTotalSize()) }) diff --git a/internal/hermes-api/test/org_test.go b/internal/hermes-api/test/org_test.go index 7b478ee5..9529413b 100644 --- a/internal/hermes-api/test/org_test.go +++ b/internal/hermes-api/test/org_test.go @@ -517,7 +517,7 @@ func TestListOrgs(t *testing.T) { }) t.Logf("nextOrgs, err: %+v, %v", nextOrgs, err) require.NoError(t, err) - require.GreaterOrEqual(t, len(nextOrgs.GetOrgs()), 1) + require.NotEmpty(t, nextOrgs.GetOrgs()) require.GreaterOrEqual(t, nextOrgs.GetTotalSize(), int32(3)) }) diff --git a/internal/hermes-api/test/session_test.go b/internal/hermes-api/test/session_test.go index f6a96e98..64ee6645 100644 --- a/internal/hermes-api/test/session_test.go +++ b/internal/hermes-api/test/session_test.go @@ -455,7 +455,7 @@ func TestListKeys(t *testing.T) { }) t.Logf("nextKeys, err: %+v, %v", nextKeys, err) require.NoError(t, err) - require.GreaterOrEqual(t, len(nextKeys.GetKeys()), 1) + require.NotEmpty(t, nextKeys.GetKeys()) require.GreaterOrEqual(t, nextKeys.GetTotalSize(), int32(3)) }) diff --git a/internal/hermes-api/test/user_test.go b/internal/hermes-api/test/user_test.go index 6e208e71..48df1048 100644 --- a/internal/hermes-api/test/user_test.go +++ b/internal/hermes-api/test/user_test.go @@ -790,7 +790,7 @@ func TestListUsers(t *testing.T) { }) t.Logf("nextUsers, err: %+v, %v", nextUsers, err) require.NoError(t, err) - require.GreaterOrEqual(t, len(nextUsers.GetUsers()), 1) + require.NotEmpty(t, nextUsers.GetUsers()) require.GreaterOrEqual(t, nextUsers.GetTotalSize(), int32(3)) }) @@ -804,7 +804,7 @@ func TestListUsers(t *testing.T) { listUsers, err := secCli.ListUsers(ctx, &api.ListUsersRequest{}) t.Logf("listUsers, err: %+v, %v", listUsers, err) require.NoError(t, err) - require.Len(t, listUsers.GetUsers(), 0) + require.Empty(t, listUsers.GetUsers()) require.Equal(t, int32(0), listUsers.GetTotalSize()) }) diff --git a/pkg/consterr/consterr_test.go b/pkg/consterr/consterr_test.go index 264a66b7..2a45b31f 100644 --- a/pkg/consterr/consterr_test.go +++ b/pkg/consterr/consterr_test.go @@ -28,7 +28,7 @@ func TestOrg(t *testing.T) { require.Equal(t, errStr, err.Error()) // Errors should compare exactly without reflection. - require.True(t, err == Error(errStr)) + require.True(t, err == Error(errStr)) //nolint:testifylint // above wrapErr := fmt.Errorf("%w: %s", err, random.String(10)) t.Logf("wrapErr: %v", wrapErr) diff --git a/pkg/dao/app/crudl_test.go b/pkg/dao/app/crudl_test.go index 521f4911..b3b3ca93 100644 --- a/pkg/dao/app/crudl_test.go +++ b/pkg/dao/app/crudl_test.go @@ -407,7 +407,7 @@ func TestList(t *testing.T) { t.Logf("listApps, listCount, err: %+v, %v, %v", listApps, listCount, err) require.NoError(t, err) - require.Len(t, listApps, 0) + require.Empty(t, listApps) require.Equal(t, int32(0), listCount) }) diff --git a/pkg/dao/event/crudl_test.go b/pkg/dao/event/crudl_test.go index ba2fbda7..56653e61 100644 --- a/pkg/dao/event/crudl_test.go +++ b/pkg/dao/event/crudl_test.go @@ -131,7 +131,7 @@ func TestList(t *testing.T) { event.GetCreatedAt().AsTime().Add(-time.Millisecond)) t.Logf("listEvents, err: %+v, %v", listEvents, err) require.NoError(t, err) - require.Len(t, listEvents, 0) + require.Empty(t, listEvents) }) t.Run("List events by invalid org ID", func(t *testing.T) { @@ -261,7 +261,7 @@ func TestLatest(t *testing.T) { event.GetIdentityId()) t.Logf("latEvents, err: %+v, %v", latEvents, err) require.NoError(t, err) - require.Len(t, latEvents, 0) + require.Empty(t, latEvents) }) t.Run("Latest events by invalid app ID", func(t *testing.T) { diff --git a/pkg/dao/identity/crudl_test.go b/pkg/dao/identity/crudl_test.go index 249c1eca..2885b870 100644 --- a/pkg/dao/identity/crudl_test.go +++ b/pkg/dao/identity/crudl_test.go @@ -841,7 +841,7 @@ func TestList(t *testing.T) { t.Logf("listIdentities, listCount, err: %+v, %v, %v", listIdentities, listCount, err) require.NoError(t, err) - require.Len(t, listIdentities, 0) + require.Empty(t, listIdentities) require.Equal(t, int32(0), listCount) }) @@ -856,7 +856,7 @@ func TestList(t *testing.T) { t.Logf("listIdentities, listCount, err: %+v, %v, %v", listIdentities, listCount, err) require.NoError(t, err) - require.Len(t, listIdentities, 0) + require.Empty(t, listIdentities) require.Equal(t, int32(0), listCount) }) diff --git a/pkg/dao/key/crudl_test.go b/pkg/dao/key/crudl_test.go index 71449514..14cd6da9 100644 --- a/pkg/dao/key/crudl_test.go +++ b/pkg/dao/key/crudl_test.go @@ -297,7 +297,7 @@ func TestList(t *testing.T) { t.Logf("listKeys, listCount, err: %+v, %v, %v", listKeys, listCount, err) require.NoError(t, err) - require.Len(t, listKeys, 0) + require.Empty(t, listKeys) require.Equal(t, int32(0), listCount) }) diff --git a/pkg/dao/user/crudl_test.go b/pkg/dao/user/crudl_test.go index 796b1645..6caaed7b 100644 --- a/pkg/dao/user/crudl_test.go +++ b/pkg/dao/user/crudl_test.go @@ -594,7 +594,7 @@ func TestList(t *testing.T) { t.Logf("listUsers, listCount, err: %+v, %v, %v", listUsers, listCount, err) require.NoError(t, err) - require.Len(t, listUsers, 0) + require.Empty(t, listUsers) require.Equal(t, int32(0), listCount) })