diff --git a/master/internal/api_experiment_intg_test.go b/master/internal/api_experiment_intg_test.go index 2ea099743d3..c28931416e9 100644 --- a/master/internal/api_experiment_intg_test.go +++ b/master/internal/api_experiment_intg_test.go @@ -1426,7 +1426,7 @@ func TestAuthZGetExperiments(t *testing.T) { authZProject.On("CanGetProject", mock.Anything, mockUserArg, mock.Anything). Return(nil).Once() expectedErr := fmt.Errorf("filterExperimentsQueryError") - authZExp.On("FilterExperimentsQuery", mock.Anything, mockUserArg, mock.Anything, mock.Anything, + authZExp.On("FilterExperimentsQuery", mock.Anything, mock.Anything, mock.Anything, []rbacv1.PermissionType{rbacv1.PermissionType_PERMISSION_TYPE_VIEW_EXPERIMENT_METADATA}). Return(nil, expectedErr).Once() _, err = api.GetExperiments(ctx, &apiv1.GetExperimentsRequest{ProjectId: int32(projectID)}) @@ -1434,7 +1434,7 @@ func TestAuthZGetExperiments(t *testing.T) { // Filter only to only one experiment ID. resQuery := &bun.SelectQuery{} - authZExp.On("FilterExperimentsQuery", mock.Anything, mockUserArg, mock.Anything, mock.Anything, + authZExp.On("FilterExperimentsQuery", mock.Anything, mockUserArg, mock.Anything, mock.Anything). Return(resQuery, nil).Once().Run(func(args mock.Arguments) { q := args.Get(3).(*bun.SelectQuery) @@ -1812,7 +1812,7 @@ func TestAuthZGetExperimentAndCanDoActions(t *testing.T) { for _, curCase := range caseIndividualThroughBulkCalls { // Return no results, get not-found error. // permissions could be UpdateExperiment or UpdateExperimentMetadata. - authZExp.On("FilterExperimentsQuery", mock.Anything, mock.Anything, mock.Anything, mock.Anything, + authZExp.On("FilterExperimentsQuery", mock.Anything, mock.Anything, mock.Anything, mock.Anything). Return(resQuery, nil).Once().Run(func(args mock.Arguments) { q := args.Get(3).(*bun.SelectQuery).Where("0 = 1") @@ -1823,7 +1823,7 @@ func TestAuthZGetExperimentAndCanDoActions(t *testing.T) { // FilterExperimentsQuery error returned unmodified. expectedErr := fmt.Errorf("canGetExperimentError") - authZExp.On("FilterExperimentsQuery", mock.Anything, mock.Anything, mock.Anything, mock.Anything, + authZExp.On("FilterExperimentsQuery", mock.Anything, mock.Anything, mock.Anything, mock.Anything). Return(resQuery, expectedErr).Once().Run(func(args mock.Arguments) { q := args.Get(3).(*bun.SelectQuery).Where("0 = 1") @@ -1894,7 +1894,7 @@ func TestAuthZGetExperimentAndCanDoActions(t *testing.T) { for _, curCase := range caseBulkCalls { // Return no results, get not-found error in results. // permissions could be UpdateExperiment or UpdateExperimentMetadata. - authZExp.On("FilterExperimentsQuery", mock.Anything, mock.Anything, mock.Anything, mock.Anything, + authZExp.On("FilterExperimentsQuery", mock.Anything, mock.Anything, mock.Anything, mock.Anything). Return(resQuery, nil).Once().Run(func(args mock.Arguments) { q := args.Get(3).(*bun.SelectQuery).Where("0 = 1") @@ -1906,7 +1906,7 @@ func TestAuthZGetExperimentAndCanDoActions(t *testing.T) { // FilterExperimentsQuery error returned unmodified. expectedErr := fmt.Errorf("canGetExperimentError") - authZExp.On("FilterExperimentsQuery", mock.Anything, mock.Anything, mock.Anything, mock.Anything, + authZExp.On("FilterExperimentsQuery", mock.Anything, mock.Anything, mock.Anything, mock.Anything). Return(resQuery, expectedErr).Once().Run(func(args mock.Arguments) { q := args.Get(3).(*bun.SelectQuery).Where("0 = 1") diff --git a/master/internal/api_project_intg_test.go b/master/internal/api_project_intg_test.go index af15ff2903f..8ff628a7113 100644 --- a/master/internal/api_project_intg_test.go +++ b/master/internal/api_project_intg_test.go @@ -251,7 +251,7 @@ func TestAuthZCanMoveProjectExperiments(t *testing.T) { Return(nil).Twice() authZExp.On("CanCreateExperiment", mock.Anything, mock.Anything, mock.Anything, mock.Anything). Return(nil).Once() - authZExp.On("FilterExperimentsQuery", mock.Anything, mock.Anything, mock.Anything, mock.Anything, + authZExp.On("FilterExperimentsQuery", mock.Anything, mock.Anything, mock.Anything, []rbacv1.PermissionType{ rbacv1.PermissionType_PERMISSION_TYPE_VIEW_EXPERIMENT_METADATA, rbacv1.PermissionType_PERMISSION_TYPE_DELETE_EXPERIMENT, diff --git a/master/internal/user/postgres_scim_users_intg_test.go b/master/internal/user/postgres_scim_users_intg_test.go index 48c56969d28..976165a770d 100644 --- a/master/internal/user/postgres_scim_users_intg_test.go +++ b/master/internal/user/postgres_scim_users_intg_test.go @@ -287,7 +287,7 @@ func TestUpdateUserAndDeleteSession(t *testing.T) { _, err = db.Bun().NewSelect().Table("user_sessions"). Where("user_id = ?", user.ID).Exec(context.Background()) - require.ErrorIs(t, errors.New("Receive unexpected error: bun: Model(nil)"), err) + require.ErrorAs(t, errors.New("Receive unexpected error: bun: Model(nil)"), &err) }) } } diff --git a/master/internal/user/postgres_users_intg_test.go b/master/internal/user/postgres_users_intg_test.go index d3110ebc509..9daa57b30c1 100644 --- a/master/internal/user/postgres_users_intg_test.go +++ b/master/internal/user/postgres_users_intg_test.go @@ -231,7 +231,7 @@ func TestDeleteSessionByToken(t *testing.T) { exists, err := db.Bun().NewSelect().Table("user_sessions"). Where("user_id = ?", userID).Exists(context.TODO()) require.False(t, exists) - require.ErrorIs(t, errors.New("Receive unexpected error: bun: Model(nil)"), err) + require.ErrorAs(t, errors.New("Receive unexpected error: bun: Model(nil)"), &err) } func TestDeleteSessionByID(t *testing.T) { @@ -244,7 +244,7 @@ func TestDeleteSessionByID(t *testing.T) { exists, err := db.Bun().NewSelect().Table("user_sessions"). Where("user_id = ?", userID).Exists(context.TODO()) require.False(t, exists) - require.ErrorIs(t, errors.New("Receive unexpected error: bun: Model(nil)"), err) + require.ErrorAs(t, errors.New("Receive unexpected error: bun: Model(nil)"), &err) } func TestUpdateUsername(t *testing.T) { diff --git a/master/pkg/checkpoints/archive/tar_archive_writer_test.go b/master/pkg/checkpoints/archive/tar_archive_writer_test.go index 549dff391b3..6adbb9a5606 100644 --- a/master/pkg/checkpoints/archive/tar_archive_writer_test.go +++ b/master/pkg/checkpoints/archive/tar_archive_writer_test.go @@ -122,7 +122,7 @@ func TestTarDryRun(t *testing.T) { _, err = tr.Next() require.Equal(t, io.EOF, err) - require.Empty(t, buf) + require.Zero(t, buf.Len()) require.Equal(t, buf.writeCount, buf.readCount) require.Equal(t, buf.writeCount, contentLength) } diff --git a/master/pkg/stream/stream_test.go b/master/pkg/stream/stream_test.go index 58148d7bd81..987c410fe5c 100644 --- a/master/pkg/stream/stream_test.go +++ b/master/pkg/stream/stream_test.go @@ -108,7 +108,7 @@ func TestConfigureSubscription(t *testing.T) { require.NotNil(t, sub2.filter, "subscription filter is nil after instantiation") sub2.Register() - require.Nil(t, sub2.filter, "subscription filter is nil after configuration") + require.NotNil(t, sub2.filter, "subscription filter is nil after configuration") require.False(t, sub2.filter(TestMsgTypeA{}), "set filter does not work") require.Len(t, publisher.Subscriptions, 2, "publisher's subscriptions are nil after configuration") @@ -137,7 +137,7 @@ func TestBroadcast(t *testing.T) { event := Event[TestMsgTypeA]{After: &afterMsg} publisher.Broadcast([]Event[TestMsgTypeA]{event}) - require.Len(t, len(streamer.Msgs), 1, "upsert message was not upserted") + require.Len(t, streamer.Msgs, 1, "upsert message was not upserted") upsertMsg, ok := streamer.Msgs[0].(UpsertMsg) require.True(t, ok, "message was not an upsert type") require.Zero(t, upsertMsg.Msg.SeqNum(), "Sequence number incorrect") @@ -348,7 +348,7 @@ func TestBroadcastSeparateEvents(t *testing.T) { event := Event[TestMsgTypeA]{After: &afterMsg} publisher.Broadcast([]Event[TestMsgTypeA]{event}) - require.Equal(t, 1, streamer.Msgs, "picked up message we don't want") + require.Len(t, streamer.Msgs, 1, "picked up message we don't want") upsertMsg, ok := streamer.Msgs[0].(UpsertMsg) require.True(t, ok, "message was not an upsert type") require.Zero(t, upsertMsg.Msg.SeqNum(), "Sequence number incorrect") diff --git a/master/pkg/syncx/queue/queue_test.go b/master/pkg/syncx/queue/queue_test.go index 17c0276ac25..9a59ab70942 100644 --- a/master/pkg/syncx/queue/queue_test.go +++ b/master/pkg/syncx/queue/queue_test.go @@ -17,13 +17,13 @@ func TestQueue(t *testing.T) { require.Zero(t, q.Len()) q.Put(1) - require.Len(t, q.Len(), 1) + require.Equal(t, q.Len(), 1) q.Put(2) - require.Len(t, q.Len(), 2) + require.Equal(t, q.Len(), 2) require.Equal(t, 1, q.Get()) - require.Len(t, q.Len(), 1) + require.Equal(t, q.Len(), 1) require.Equal(t, 2, q.Get()) require.Zero(t, q.Len()) @@ -118,12 +118,12 @@ func TestQueueMultipleBlockedReaders(t *testing.T) { require.Len(t, in, numDone, "all goroutines should have unblocked") require.ElementsMatch(t, in, out, "should have gotten all values") - require.Empty(t, q) + require.Zero(t, q.Len()) } func TestQueueConcurrent(t *testing.T) { q := queue.New[int]() - require.Empty(t, q) + require.Zero(t, q.Len()) var in []int for i := 0; i < 100; i++ {