Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
carolinaecalderon committed May 6, 2024
1 parent 77917c7 commit 7dbdd86
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 19 deletions.
12 changes: 6 additions & 6 deletions master/internal/api_experiment_intg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1426,15 +1426,15 @@ 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)})
require.Equal(t, expectedErr, err)

// 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)
Expand Down Expand Up @@ -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")
Expand All @@ -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")
Expand Down Expand Up @@ -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")
Expand All @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion master/internal/api_project_intg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion master/internal/user/postgres_scim_users_intg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}
}
Expand Down
4 changes: 2 additions & 2 deletions master/internal/user/postgres_users_intg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion master/pkg/checkpoints/archive/tar_archive_writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
6 changes: 3 additions & 3 deletions master/pkg/stream/stream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down
10 changes: 5 additions & 5 deletions master/pkg/syncx/queue/queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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++ {
Expand Down

0 comments on commit 7dbdd86

Please sign in to comment.