diff --git a/aggregator/aggregator.go b/aggregator/aggregator.go index bd5d1c8..33a5285 100644 --- a/aggregator/aggregator.go +++ b/aggregator/aggregator.go @@ -22,12 +22,12 @@ import ( ) //go:generate mockgen -source=aggregator.go -destination=../mock/aggregator.mock.go -package=mocks -type iAggregator[T any] interface { +type IAggregator[T any] interface { Aggregate(ctx context.Context, opts ...options.Lister[options.AggregateOptions]) ([]*T, error) AggregateWithParse(ctx context.Context, result any, opts ...options.Lister[options.AggregateOptions]) error } -var _ iAggregator[any] = (*Aggregator[any])(nil) +var _ IAggregator[any] = (*Aggregator[any])(nil) type Aggregator[T any] struct { collection *mongo.Collection diff --git a/aggregator/aggregator_test.go b/aggregator/aggregator_test.go index 1b73e6e..54fcb1c 100644 --- a/aggregator/aggregator_test.go +++ b/aggregator/aggregator_test.go @@ -80,15 +80,15 @@ func TestAggregator_New(t *testing.T) { func TestAggregator_Aggregation(t *testing.T) { testCases := []struct { name string - mock func(ctx context.Context, ctl *gomock.Controller) iAggregator[TestUser] + mock func(ctx context.Context, ctl *gomock.Controller) IAggregator[TestUser] ctx context.Context want []*TestUser wantErr assert.ErrorAssertionFunc }{ { name: "got error", - mock: func(ctx context.Context, ctl *gomock.Controller) iAggregator[TestUser] { - aggregator := mocks.NewMockiAggregator[TestUser](ctl) + mock: func(ctx context.Context, ctl *gomock.Controller) IAggregator[TestUser] { + aggregator := mocks.NewMockIAggregator[TestUser](ctl) aggregator.EXPECT().Aggregate(ctx).Return(nil, errors.New("can only marshal slices and arrays into aggregation pipelines, but got invalid")).Times(1) return aggregator }, @@ -97,8 +97,8 @@ func TestAggregator_Aggregation(t *testing.T) { }, { name: "got result", - mock: func(ctx context.Context, ctl *gomock.Controller) iAggregator[TestUser] { - aggregator := mocks.NewMockiAggregator[TestUser](ctl) + mock: func(ctx context.Context, ctl *gomock.Controller) IAggregator[TestUser] { + aggregator := mocks.NewMockIAggregator[TestUser](ctl) aggregator.EXPECT().Aggregate(ctx).Return([]*TestUser{ {Name: "chenmingyong", Age: 24}, {Name: "gopher", Age: 25}, @@ -136,7 +136,7 @@ func TestAggregator_AggregateWithParse(t *testing.T) { } testCases := []struct { name string - mock func(ctx context.Context, ctl *gomock.Controller, result any) iAggregator[TestUser] + mock func(ctx context.Context, ctl *gomock.Controller, result any) IAggregator[TestUser] ctx context.Context result []*User want []*User @@ -144,8 +144,8 @@ func TestAggregator_AggregateWithParse(t *testing.T) { }{ { name: "got error", - mock: func(ctx context.Context, ctl *gomock.Controller, result any) iAggregator[TestUser] { - aggregator := mocks.NewMockiAggregator[TestUser](ctl) + mock: func(ctx context.Context, ctl *gomock.Controller, result any) IAggregator[TestUser] { + aggregator := mocks.NewMockIAggregator[TestUser](ctl) aggregator.EXPECT().AggregateWithParse(ctx, result).Return(errors.New("can only marshal slices and arrays into aggregation pipelines, but got invalid")).Times(1) return aggregator }, @@ -155,8 +155,8 @@ func TestAggregator_AggregateWithParse(t *testing.T) { }, { name: "got result", - mock: func(ctx context.Context, ctl *gomock.Controller, result any) iAggregator[TestUser] { - aggregator := mocks.NewMockiAggregator[TestUser](ctl) + mock: func(ctx context.Context, ctl *gomock.Controller, result any) IAggregator[TestUser] { + aggregator := mocks.NewMockIAggregator[TestUser](ctl) aggregator.EXPECT().AggregateWithParse(ctx, result).Return(nil).Times(1) return aggregator }, diff --git a/creator/creator.go b/creator/creator.go index 8c3f85c..ea5c1e9 100644 --- a/creator/creator.go +++ b/creator/creator.go @@ -27,12 +27,12 @@ import ( ) //go:generate mockgen -source=creator.go -destination=../mock/creator.mock.go -package=mocks -type iCreator[T any] interface { +type ICreator[T any] interface { InsertOne(ctx context.Context, docs *T, opts ...options.Lister[options.InsertOneOptions]) (*mongo.InsertOneResult, error) InsertMany(ctx context.Context, docs []*T, opts ...options.Lister[options.InsertManyOptions]) (*mongo.InsertManyResult, error) } -var _ iCreator[any] = (*Creator[any])(nil) +var _ ICreator[any] = (*Creator[any])(nil) type Creator[T any] struct { collection *mongo.Collection diff --git a/creator/creator_test.go b/creator/creator_test.go index edf59af..aaef013 100644 --- a/creator/creator_test.go +++ b/creator/creator_test.go @@ -58,7 +58,7 @@ func TestNewCreator(t *testing.T) { func TestCreator_One(t *testing.T) { testCases := []struct { name string - mock func(ctx context.Context, ctl *gomock.Controller, doc *TestUser) iCreator[TestUser] + mock func(ctx context.Context, ctl *gomock.Controller, doc *TestUser) ICreator[TestUser] ctx context.Context doc *TestUser @@ -66,8 +66,8 @@ func TestCreator_One(t *testing.T) { }{ { name: "nil doc", - mock: func(ctx context.Context, ctl *gomock.Controller, doc *TestUser) iCreator[TestUser] { - mockCollection := mocks.NewMockiCreator[TestUser](ctl) + mock: func(ctx context.Context, ctl *gomock.Controller, doc *TestUser) ICreator[TestUser] { + mockCollection := mocks.NewMockICreator[TestUser](ctl) mockCollection.EXPECT().InsertOne(ctx, doc).Return(nil, errors.New("nil filter")).Times(1) return mockCollection }, @@ -77,8 +77,8 @@ func TestCreator_One(t *testing.T) { }, { name: "success", - mock: func(ctx context.Context, ctl *gomock.Controller, doc *TestUser) iCreator[TestUser] { - mockCollection := mocks.NewMockiCreator[TestUser](ctl) + mock: func(ctx context.Context, ctl *gomock.Controller, doc *TestUser) ICreator[TestUser] { + mockCollection := mocks.NewMockICreator[TestUser](ctl) mockCollection.EXPECT().InsertOne(ctx, doc).Return(&mongo.InsertOneResult{InsertedID: "?"}, nil).Times(1) return mockCollection }, @@ -107,7 +107,7 @@ func TestCreator_One(t *testing.T) { func TestCreator_Many(t *testing.T) { testCases := []struct { name string - mock func(ctx context.Context, ctl *gomock.Controller, docs []*TestUser) iCreator[TestUser] + mock func(ctx context.Context, ctl *gomock.Controller, docs []*TestUser) ICreator[TestUser] ctx context.Context docs []*TestUser @@ -116,8 +116,8 @@ func TestCreator_Many(t *testing.T) { }{ { name: "nil docs", - mock: func(ctx context.Context, ctl *gomock.Controller, docs []*TestUser) iCreator[TestUser] { - mockCollection := mocks.NewMockiCreator[TestUser](ctl) + mock: func(ctx context.Context, ctl *gomock.Controller, docs []*TestUser) ICreator[TestUser] { + mockCollection := mocks.NewMockICreator[TestUser](ctl) mockCollection.EXPECT().InsertMany(ctx, docs).Return(nil, errors.New("nil docs")).Times(1) return mockCollection }, @@ -130,8 +130,8 @@ func TestCreator_Many(t *testing.T) { }, { name: "success", - mock: func(ctx context.Context, ctl *gomock.Controller, docs []*TestUser) iCreator[TestUser] { - mockCollection := mocks.NewMockiCreator[TestUser](ctl) + mock: func(ctx context.Context, ctl *gomock.Controller, docs []*TestUser) ICreator[TestUser] { + mockCollection := mocks.NewMockICreator[TestUser](ctl) mockCollection.EXPECT().InsertMany(ctx, docs).Return(&mongo.InsertManyResult{InsertedIDs: make([]interface{}, 2)}, nil).Times(1) return mockCollection }, diff --git a/deleter/deleter.go b/deleter/deleter.go index 3148db4..801ce8d 100644 --- a/deleter/deleter.go +++ b/deleter/deleter.go @@ -25,12 +25,12 @@ import ( ) //go:generate mockgen -source=deleter.go -destination=../mock/deleter.mock.go -package=mocks -type iDeleter[T any] interface { +type IDeleter[T any] interface { DeleteOne(ctx context.Context, opts ...options.Lister[options.DeleteOptions]) (*mongo.DeleteResult, error) DeleteMany(ctx context.Context, opts ...options.Lister[options.DeleteOptions]) (*mongo.DeleteResult, error) } -var _ iDeleter[any] = (*Deleter[any])(nil) +var _ IDeleter[any] = (*Deleter[any])(nil) func NewDeleter[T any](collection *mongo.Collection) *Deleter[T] { return &Deleter[T]{collection: collection, filter: nil} diff --git a/deleter/deleter_test.go b/deleter/deleter_test.go index 1ef652c..812b8f9 100644 --- a/deleter/deleter_test.go +++ b/deleter/deleter_test.go @@ -59,7 +59,7 @@ func TestDeleter_DeleteOne(t *testing.T) { testCases := []struct { name string - mock func(ctx context.Context, ctl *gomock.Controller) iDeleter[TestUser] + mock func(ctx context.Context, ctl *gomock.Controller) IDeleter[TestUser] ctx context.Context want *mongo.DeleteResult @@ -67,8 +67,8 @@ func TestDeleter_DeleteOne(t *testing.T) { }{ { name: "error: nil filter", - mock: func(ctx context.Context, ctl *gomock.Controller) iDeleter[TestUser] { - mockCollection := mocks.NewMockiDeleter[TestUser](ctl) + mock: func(ctx context.Context, ctl *gomock.Controller) IDeleter[TestUser] { + mockCollection := mocks.NewMockIDeleter[TestUser](ctl) mockCollection.EXPECT().DeleteOne(ctx).Return(nil, errors.New("nil filter")).Times(1) return mockCollection }, @@ -79,8 +79,8 @@ func TestDeleter_DeleteOne(t *testing.T) { }, { name: "deleted count: 0", - mock: func(ctx context.Context, ctl *gomock.Controller) iDeleter[TestUser] { - mockCollection := mocks.NewMockiDeleter[TestUser](ctl) + mock: func(ctx context.Context, ctl *gomock.Controller) IDeleter[TestUser] { + mockCollection := mocks.NewMockIDeleter[TestUser](ctl) mockCollection.EXPECT().DeleteOne(ctx).Return(&mongo.DeleteResult{DeletedCount: 0}, nil).Times(1) return mockCollection }, @@ -92,8 +92,8 @@ func TestDeleter_DeleteOne(t *testing.T) { }, { name: "delete success", - mock: func(ctx context.Context, ctl *gomock.Controller) iDeleter[TestUser] { - mockCollection := mocks.NewMockiDeleter[TestUser](ctl) + mock: func(ctx context.Context, ctl *gomock.Controller) IDeleter[TestUser] { + mockCollection := mocks.NewMockIDeleter[TestUser](ctl) mockCollection.EXPECT().DeleteOne(ctx).Return(&mongo.DeleteResult{DeletedCount: 1}, nil).Times(1) return mockCollection }, @@ -124,7 +124,7 @@ func TestDeleter_DeleteMany(t *testing.T) { testCases := []struct { name string - mock func(ctx context.Context, ctl *gomock.Controller) iDeleter[TestUser] + mock func(ctx context.Context, ctl *gomock.Controller) IDeleter[TestUser] ctx context.Context want *mongo.DeleteResult @@ -132,8 +132,8 @@ func TestDeleter_DeleteMany(t *testing.T) { }{ { name: "error: nil filter", - mock: func(ctx context.Context, ctl *gomock.Controller) iDeleter[TestUser] { - mockCollection := mocks.NewMockiDeleter[TestUser](ctl) + mock: func(ctx context.Context, ctl *gomock.Controller) IDeleter[TestUser] { + mockCollection := mocks.NewMockIDeleter[TestUser](ctl) mockCollection.EXPECT().DeleteMany(ctx).Return(nil, errors.New("nil filter")).Times(1) return mockCollection }, @@ -144,8 +144,8 @@ func TestDeleter_DeleteMany(t *testing.T) { }, { name: "deleted count: 0", - mock: func(ctx context.Context, ctl *gomock.Controller) iDeleter[TestUser] { - mockCollection := mocks.NewMockiDeleter[TestUser](ctl) + mock: func(ctx context.Context, ctl *gomock.Controller) IDeleter[TestUser] { + mockCollection := mocks.NewMockIDeleter[TestUser](ctl) mockCollection.EXPECT().DeleteMany(ctx).Return(&mongo.DeleteResult{DeletedCount: 0}, nil).Times(1) return mockCollection }, @@ -157,8 +157,8 @@ func TestDeleter_DeleteMany(t *testing.T) { }, { name: "delete success", - mock: func(ctx context.Context, ctl *gomock.Controller) iDeleter[TestUser] { - mockCollection := mocks.NewMockiDeleter[TestUser](ctl) + mock: func(ctx context.Context, ctl *gomock.Controller) IDeleter[TestUser] { + mockCollection := mocks.NewMockIDeleter[TestUser](ctl) mockCollection.EXPECT().DeleteMany(ctx).Return(&mongo.DeleteResult{DeletedCount: 2}, nil).Times(1) return mockCollection }, diff --git a/finder/finder.go b/finder/finder.go index 290fa70..efb6db3 100644 --- a/finder/finder.go +++ b/finder/finder.go @@ -26,7 +26,7 @@ import ( ) //go:generate mockgen -source=finder.go -destination=../mock/finder.mock.go -package=mocks -type iFinder[T any] interface { +type IFinder[T any] interface { FindOne(ctx context.Context, opts ...options.Lister[options.FindOneOptions]) (*T, error) Find(ctx context.Context, opts ...options.Lister[options.FindOptions]) ([]*T, error) Count(ctx context.Context, opts ...options.Lister[options.CountOptions]) (int64, error) @@ -36,7 +36,7 @@ func NewFinder[T any](collection *mongo.Collection) *Finder[T] { return &Finder[T]{collection: collection, filter: bson.D{}} } -var _ iFinder[any] = (*Finder[any])(nil) +var _ IFinder[any] = (*Finder[any])(nil) type Finder[T any] struct { collection *mongo.Collection diff --git a/finder/finder_test.go b/finder/finder_test.go index 4f85ce2..28913a8 100644 --- a/finder/finder_test.go +++ b/finder/finder_test.go @@ -37,7 +37,7 @@ func TestFinder_New(t *testing.T) { func TestFinder_One(t *testing.T) { testCases := []struct { name string - mock func(ctx context.Context, ctl *gomock.Controller) iFinder[TestUser] + mock func(ctx context.Context, ctl *gomock.Controller) IFinder[TestUser] ctx context.Context want *TestUser @@ -45,8 +45,8 @@ func TestFinder_One(t *testing.T) { }{ { name: "error", - mock: func(ctx context.Context, ctl *gomock.Controller) iFinder[TestUser] { - mockCollection := mocks.NewMockiFinder[TestUser](ctl) + mock: func(ctx context.Context, ctl *gomock.Controller) IFinder[TestUser] { + mockCollection := mocks.NewMockIFinder[TestUser](ctl) mockCollection.EXPECT().FindOne(gomock.Any()).Return(nil, mongo.ErrNoDocuments).Times(1) return mockCollection }, @@ -54,8 +54,8 @@ func TestFinder_One(t *testing.T) { }, { name: "match the first one", - mock: func(ctx context.Context, ctl *gomock.Controller) iFinder[TestUser] { - mockCollection := mocks.NewMockiFinder[TestUser](ctl) + mock: func(ctx context.Context, ctl *gomock.Controller) IFinder[TestUser] { + mockCollection := mocks.NewMockIFinder[TestUser](ctl) mockCollection.EXPECT().FindOne(gomock.Any()).Return(&TestUser{ Name: "chenmingyong", Age: 24, @@ -84,7 +84,7 @@ func TestFinder_One(t *testing.T) { func TestFinder_All(t *testing.T) { testCases := []struct { name string - mock func(ctx context.Context, ctl *gomock.Controller) iFinder[TestUser] + mock func(ctx context.Context, ctl *gomock.Controller) IFinder[TestUser] ctx context.Context want []*TestUser @@ -92,8 +92,8 @@ func TestFinder_All(t *testing.T) { }{ { name: "empty documents", - mock: func(ctx context.Context, ctl *gomock.Controller) iFinder[TestUser] { - mockCollection := mocks.NewMockiFinder[TestUser](ctl) + mock: func(ctx context.Context, ctl *gomock.Controller) IFinder[TestUser] { + mockCollection := mocks.NewMockIFinder[TestUser](ctl) mockCollection.EXPECT().Find(ctx).Return([]*TestUser{}, nil).Times(1) return mockCollection }, @@ -101,8 +101,8 @@ func TestFinder_All(t *testing.T) { }, { name: "matched", - mock: func(ctx context.Context, ctl *gomock.Controller) iFinder[TestUser] { - mockCollection := mocks.NewMockiFinder[TestUser](ctl) + mock: func(ctx context.Context, ctl *gomock.Controller) IFinder[TestUser] { + mockCollection := mocks.NewMockIFinder[TestUser](ctl) mockCollection.EXPECT().Find(ctx).Return([]*TestUser{ { Name: "chenmingyong", @@ -143,7 +143,7 @@ func TestFinder_All(t *testing.T) { func TestFinder_Count(t *testing.T) { testCases := []struct { name string - mock func(ctx context.Context, ctl *gomock.Controller) iFinder[TestUser] + mock func(ctx context.Context, ctl *gomock.Controller) IFinder[TestUser] ctx context.Context want int64 @@ -151,8 +151,8 @@ func TestFinder_Count(t *testing.T) { }{ { name: "error", - mock: func(ctx context.Context, ctl *gomock.Controller) iFinder[TestUser] { - mockCollection := mocks.NewMockiFinder[TestUser](ctl) + mock: func(ctx context.Context, ctl *gomock.Controller) IFinder[TestUser] { + mockCollection := mocks.NewMockIFinder[TestUser](ctl) mockCollection.EXPECT().Count(ctx).Return(int64(0), errors.New("nil filter error")).Times(1) return mockCollection }, @@ -161,8 +161,8 @@ func TestFinder_Count(t *testing.T) { }, { name: "matched 0", - mock: func(ctx context.Context, ctl *gomock.Controller) iFinder[TestUser] { - mockCollection := mocks.NewMockiFinder[TestUser](ctl) + mock: func(ctx context.Context, ctl *gomock.Controller) IFinder[TestUser] { + mockCollection := mocks.NewMockIFinder[TestUser](ctl) mockCollection.EXPECT().Count(ctx).Return(int64(0), nil).Times(1) return mockCollection }, @@ -170,8 +170,8 @@ func TestFinder_Count(t *testing.T) { }, { name: "matched 1", - mock: func(ctx context.Context, ctl *gomock.Controller) iFinder[TestUser] { - mockCollection := mocks.NewMockiFinder[TestUser](ctl) + mock: func(ctx context.Context, ctl *gomock.Controller) IFinder[TestUser] { + mockCollection := mocks.NewMockIFinder[TestUser](ctl) mockCollection.EXPECT().Count(ctx).Return(int64(1), nil).Times(1) return mockCollection }, diff --git a/mock/aggregator.mock.go b/mock/aggregator.mock.go index 350e640..ff6bad8 100644 --- a/mock/aggregator.mock.go +++ b/mock/aggregator.mock.go @@ -16,31 +16,31 @@ import ( gomock "go.uber.org/mock/gomock" ) -// MockiAggregator is a mock of iAggregator interface. -type MockiAggregator[T any] struct { +// MockIAggregator is a mock of IAggregator interface. +type MockIAggregator[T any] struct { ctrl *gomock.Controller - recorder *MockiAggregatorMockRecorder[T] + recorder *MockIAggregatorMockRecorder[T] } -// MockiAggregatorMockRecorder is the mock recorder for MockiAggregator. -type MockiAggregatorMockRecorder[T any] struct { - mock *MockiAggregator[T] +// MockIAggregatorMockRecorder is the mock recorder for MockIAggregator. +type MockIAggregatorMockRecorder[T any] struct { + mock *MockIAggregator[T] } -// NewMockiAggregator creates a new mock instance. -func NewMockiAggregator[T any](ctrl *gomock.Controller) *MockiAggregator[T] { - mock := &MockiAggregator[T]{ctrl: ctrl} - mock.recorder = &MockiAggregatorMockRecorder[T]{mock} +// NewMockIAggregator creates a new mock instance. +func NewMockIAggregator[T any](ctrl *gomock.Controller) *MockIAggregator[T] { + mock := &MockIAggregator[T]{ctrl: ctrl} + mock.recorder = &MockIAggregatorMockRecorder[T]{mock} return mock } // EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockiAggregator[T]) EXPECT() *MockiAggregatorMockRecorder[T] { +func (m *MockIAggregator[T]) EXPECT() *MockIAggregatorMockRecorder[T] { return m.recorder } // Aggregate mocks base method. -func (m *MockiAggregator[T]) Aggregate(ctx context.Context, opts ...options.Lister[options.AggregateOptions]) ([]*T, error) { +func (m *MockIAggregator[T]) Aggregate(ctx context.Context, opts ...options.Lister[options.AggregateOptions]) ([]*T, error) { m.ctrl.T.Helper() varargs := []any{ctx} for _, a := range opts { @@ -53,14 +53,14 @@ func (m *MockiAggregator[T]) Aggregate(ctx context.Context, opts ...options.List } // Aggregate indicates an expected call of Aggregate. -func (mr *MockiAggregatorMockRecorder[T]) Aggregate(ctx any, opts ...any) *gomock.Call { +func (mr *MockIAggregatorMockRecorder[T]) Aggregate(ctx any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() varargs := append([]any{ctx}, opts...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Aggregate", reflect.TypeOf((*MockiAggregator[T])(nil).Aggregate), varargs...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Aggregate", reflect.TypeOf((*MockIAggregator[T])(nil).Aggregate), varargs...) } // AggregateWithParse mocks base method. -func (m *MockiAggregator[T]) AggregateWithParse(ctx context.Context, result any, opts ...options.Lister[options.AggregateOptions]) error { +func (m *MockIAggregator[T]) AggregateWithParse(ctx context.Context, result any, opts ...options.Lister[options.AggregateOptions]) error { m.ctrl.T.Helper() varargs := []any{ctx, result} for _, a := range opts { @@ -72,8 +72,8 @@ func (m *MockiAggregator[T]) AggregateWithParse(ctx context.Context, result any, } // AggregateWithParse indicates an expected call of AggregateWithParse. -func (mr *MockiAggregatorMockRecorder[T]) AggregateWithParse(ctx, result any, opts ...any) *gomock.Call { +func (mr *MockIAggregatorMockRecorder[T]) AggregateWithParse(ctx, result any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() varargs := append([]any{ctx, result}, opts...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AggregateWithParse", reflect.TypeOf((*MockiAggregator[T])(nil).AggregateWithParse), varargs...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AggregateWithParse", reflect.TypeOf((*MockIAggregator[T])(nil).AggregateWithParse), varargs...) } diff --git a/mock/creator.mock.go b/mock/creator.mock.go index 951ea59..0265a2b 100644 --- a/mock/creator.mock.go +++ b/mock/creator.mock.go @@ -17,31 +17,31 @@ import ( gomock "go.uber.org/mock/gomock" ) -// MockiCreator is a mock of iCreator interface. -type MockiCreator[T any] struct { +// MockICreator is a mock of ICreator interface. +type MockICreator[T any] struct { ctrl *gomock.Controller - recorder *MockiCreatorMockRecorder[T] + recorder *MockICreatorMockRecorder[T] } -// MockiCreatorMockRecorder is the mock recorder for MockiCreator. -type MockiCreatorMockRecorder[T any] struct { - mock *MockiCreator[T] +// MockICreatorMockRecorder is the mock recorder for MockICreator. +type MockICreatorMockRecorder[T any] struct { + mock *MockICreator[T] } -// NewMockiCreator creates a new mock instance. -func NewMockiCreator[T any](ctrl *gomock.Controller) *MockiCreator[T] { - mock := &MockiCreator[T]{ctrl: ctrl} - mock.recorder = &MockiCreatorMockRecorder[T]{mock} +// NewMockICreator creates a new mock instance. +func NewMockICreator[T any](ctrl *gomock.Controller) *MockICreator[T] { + mock := &MockICreator[T]{ctrl: ctrl} + mock.recorder = &MockICreatorMockRecorder[T]{mock} return mock } // EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockiCreator[T]) EXPECT() *MockiCreatorMockRecorder[T] { +func (m *MockICreator[T]) EXPECT() *MockICreatorMockRecorder[T] { return m.recorder } // InsertMany mocks base method. -func (m *MockiCreator[T]) InsertMany(ctx context.Context, docs []*T, opts ...options.Lister[options.InsertManyOptions]) (*mongo.InsertManyResult, error) { +func (m *MockICreator[T]) InsertMany(ctx context.Context, docs []*T, opts ...options.Lister[options.InsertManyOptions]) (*mongo.InsertManyResult, error) { m.ctrl.T.Helper() varargs := []any{ctx, docs} for _, a := range opts { @@ -54,14 +54,14 @@ func (m *MockiCreator[T]) InsertMany(ctx context.Context, docs []*T, opts ...opt } // InsertMany indicates an expected call of InsertMany. -func (mr *MockiCreatorMockRecorder[T]) InsertMany(ctx, docs any, opts ...any) *gomock.Call { +func (mr *MockICreatorMockRecorder[T]) InsertMany(ctx, docs any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() varargs := append([]any{ctx, docs}, opts...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "InsertMany", reflect.TypeOf((*MockiCreator[T])(nil).InsertMany), varargs...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "InsertMany", reflect.TypeOf((*MockICreator[T])(nil).InsertMany), varargs...) } // InsertOne mocks base method. -func (m *MockiCreator[T]) InsertOne(ctx context.Context, docs *T, opts ...options.Lister[options.InsertOneOptions]) (*mongo.InsertOneResult, error) { +func (m *MockICreator[T]) InsertOne(ctx context.Context, docs *T, opts ...options.Lister[options.InsertOneOptions]) (*mongo.InsertOneResult, error) { m.ctrl.T.Helper() varargs := []any{ctx, docs} for _, a := range opts { @@ -74,8 +74,8 @@ func (m *MockiCreator[T]) InsertOne(ctx context.Context, docs *T, opts ...option } // InsertOne indicates an expected call of InsertOne. -func (mr *MockiCreatorMockRecorder[T]) InsertOne(ctx, docs any, opts ...any) *gomock.Call { +func (mr *MockICreatorMockRecorder[T]) InsertOne(ctx, docs any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() varargs := append([]any{ctx, docs}, opts...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "InsertOne", reflect.TypeOf((*MockiCreator[T])(nil).InsertOne), varargs...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "InsertOne", reflect.TypeOf((*MockICreator[T])(nil).InsertOne), varargs...) } diff --git a/mock/deleter.mock.go b/mock/deleter.mock.go index fb88ffb..ea2ef31 100644 --- a/mock/deleter.mock.go +++ b/mock/deleter.mock.go @@ -17,31 +17,31 @@ import ( gomock "go.uber.org/mock/gomock" ) -// MockiDeleter is a mock of iDeleter interface. -type MockiDeleter[T any] struct { +// MockIDeleter is a mock of IDeleter interface. +type MockIDeleter[T any] struct { ctrl *gomock.Controller - recorder *MockiDeleterMockRecorder[T] + recorder *MockIDeleterMockRecorder[T] } -// MockiDeleterMockRecorder is the mock recorder for MockiDeleter. -type MockiDeleterMockRecorder[T any] struct { - mock *MockiDeleter[T] +// MockIDeleterMockRecorder is the mock recorder for MockIDeleter. +type MockIDeleterMockRecorder[T any] struct { + mock *MockIDeleter[T] } -// NewMockiDeleter creates a new mock instance. -func NewMockiDeleter[T any](ctrl *gomock.Controller) *MockiDeleter[T] { - mock := &MockiDeleter[T]{ctrl: ctrl} - mock.recorder = &MockiDeleterMockRecorder[T]{mock} +// NewMockIDeleter creates a new mock instance. +func NewMockIDeleter[T any](ctrl *gomock.Controller) *MockIDeleter[T] { + mock := &MockIDeleter[T]{ctrl: ctrl} + mock.recorder = &MockIDeleterMockRecorder[T]{mock} return mock } // EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockiDeleter[T]) EXPECT() *MockiDeleterMockRecorder[T] { +func (m *MockIDeleter[T]) EXPECT() *MockIDeleterMockRecorder[T] { return m.recorder } // DeleteMany mocks base method. -func (m *MockiDeleter[T]) DeleteMany(ctx context.Context, opts ...options.Lister[options.DeleteOptions]) (*mongo.DeleteResult, error) { +func (m *MockIDeleter[T]) DeleteMany(ctx context.Context, opts ...options.Lister[options.DeleteOptions]) (*mongo.DeleteResult, error) { m.ctrl.T.Helper() varargs := []any{ctx} for _, a := range opts { @@ -54,14 +54,14 @@ func (m *MockiDeleter[T]) DeleteMany(ctx context.Context, opts ...options.Lister } // DeleteMany indicates an expected call of DeleteMany. -func (mr *MockiDeleterMockRecorder[T]) DeleteMany(ctx any, opts ...any) *gomock.Call { +func (mr *MockIDeleterMockRecorder[T]) DeleteMany(ctx any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() varargs := append([]any{ctx}, opts...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteMany", reflect.TypeOf((*MockiDeleter[T])(nil).DeleteMany), varargs...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteMany", reflect.TypeOf((*MockIDeleter[T])(nil).DeleteMany), varargs...) } // DeleteOne mocks base method. -func (m *MockiDeleter[T]) DeleteOne(ctx context.Context, opts ...options.Lister[options.DeleteOptions]) (*mongo.DeleteResult, error) { +func (m *MockIDeleter[T]) DeleteOne(ctx context.Context, opts ...options.Lister[options.DeleteOptions]) (*mongo.DeleteResult, error) { m.ctrl.T.Helper() varargs := []any{ctx} for _, a := range opts { @@ -74,8 +74,8 @@ func (m *MockiDeleter[T]) DeleteOne(ctx context.Context, opts ...options.Lister[ } // DeleteOne indicates an expected call of DeleteOne. -func (mr *MockiDeleterMockRecorder[T]) DeleteOne(ctx any, opts ...any) *gomock.Call { +func (mr *MockIDeleterMockRecorder[T]) DeleteOne(ctx any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() varargs := append([]any{ctx}, opts...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteOne", reflect.TypeOf((*MockiDeleter[T])(nil).DeleteOne), varargs...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteOne", reflect.TypeOf((*MockIDeleter[T])(nil).DeleteOne), varargs...) } diff --git a/mock/finder.mock.go b/mock/finder.mock.go index e8c08fc..2a18d16 100644 --- a/mock/finder.mock.go +++ b/mock/finder.mock.go @@ -16,31 +16,31 @@ import ( gomock "go.uber.org/mock/gomock" ) -// MockiFinder is a mock of iFinder interface. -type MockiFinder[T any] struct { +// MockIFinder is a mock of IFinder interface. +type MockIFinder[T any] struct { ctrl *gomock.Controller - recorder *MockiFinderMockRecorder[T] + recorder *MockIFinderMockRecorder[T] } -// MockiFinderMockRecorder is the mock recorder for MockiFinder. -type MockiFinderMockRecorder[T any] struct { - mock *MockiFinder[T] +// MockIFinderMockRecorder is the mock recorder for MockIFinder. +type MockIFinderMockRecorder[T any] struct { + mock *MockIFinder[T] } -// NewMockiFinder creates a new mock instance. -func NewMockiFinder[T any](ctrl *gomock.Controller) *MockiFinder[T] { - mock := &MockiFinder[T]{ctrl: ctrl} - mock.recorder = &MockiFinderMockRecorder[T]{mock} +// NewMockIFinder creates a new mock instance. +func NewMockIFinder[T any](ctrl *gomock.Controller) *MockIFinder[T] { + mock := &MockIFinder[T]{ctrl: ctrl} + mock.recorder = &MockIFinderMockRecorder[T]{mock} return mock } // EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockiFinder[T]) EXPECT() *MockiFinderMockRecorder[T] { +func (m *MockIFinder[T]) EXPECT() *MockIFinderMockRecorder[T] { return m.recorder } // Count mocks base method. -func (m *MockiFinder[T]) Count(ctx context.Context, opts ...options.Lister[options.CountOptions]) (int64, error) { +func (m *MockIFinder[T]) Count(ctx context.Context, opts ...options.Lister[options.CountOptions]) (int64, error) { m.ctrl.T.Helper() varargs := []any{ctx} for _, a := range opts { @@ -53,14 +53,14 @@ func (m *MockiFinder[T]) Count(ctx context.Context, opts ...options.Lister[optio } // Count indicates an expected call of Count. -func (mr *MockiFinderMockRecorder[T]) Count(ctx any, opts ...any) *gomock.Call { +func (mr *MockIFinderMockRecorder[T]) Count(ctx any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() varargs := append([]any{ctx}, opts...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Count", reflect.TypeOf((*MockiFinder[T])(nil).Count), varargs...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Count", reflect.TypeOf((*MockIFinder[T])(nil).Count), varargs...) } // Find mocks base method. -func (m *MockiFinder[T]) Find(ctx context.Context, opts ...options.Lister[options.FindOptions]) ([]*T, error) { +func (m *MockIFinder[T]) Find(ctx context.Context, opts ...options.Lister[options.FindOptions]) ([]*T, error) { m.ctrl.T.Helper() varargs := []any{ctx} for _, a := range opts { @@ -73,14 +73,14 @@ func (m *MockiFinder[T]) Find(ctx context.Context, opts ...options.Lister[option } // Find indicates an expected call of Find. -func (mr *MockiFinderMockRecorder[T]) Find(ctx any, opts ...any) *gomock.Call { +func (mr *MockIFinderMockRecorder[T]) Find(ctx any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() varargs := append([]any{ctx}, opts...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Find", reflect.TypeOf((*MockiFinder[T])(nil).Find), varargs...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Find", reflect.TypeOf((*MockIFinder[T])(nil).Find), varargs...) } // FindOne mocks base method. -func (m *MockiFinder[T]) FindOne(ctx context.Context, opts ...options.Lister[options.FindOneOptions]) (*T, error) { +func (m *MockIFinder[T]) FindOne(ctx context.Context, opts ...options.Lister[options.FindOneOptions]) (*T, error) { m.ctrl.T.Helper() varargs := []any{ctx} for _, a := range opts { @@ -93,8 +93,8 @@ func (m *MockiFinder[T]) FindOne(ctx context.Context, opts ...options.Lister[opt } // FindOne indicates an expected call of FindOne. -func (mr *MockiFinderMockRecorder[T]) FindOne(ctx any, opts ...any) *gomock.Call { +func (mr *MockIFinderMockRecorder[T]) FindOne(ctx any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() varargs := append([]any{ctx}, opts...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindOne", reflect.TypeOf((*MockiFinder[T])(nil).FindOne), varargs...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindOne", reflect.TypeOf((*MockIFinder[T])(nil).FindOne), varargs...) } diff --git a/mock/updater.mock.go b/mock/updater.mock.go index a584a7c..2247c14 100644 --- a/mock/updater.mock.go +++ b/mock/updater.mock.go @@ -17,31 +17,31 @@ import ( gomock "go.uber.org/mock/gomock" ) -// MockiUpdater is a mock of iUpdater interface. -type MockiUpdater[T any] struct { +// MockIUpdater is a mock of IUpdater interface. +type MockIUpdater[T any] struct { ctrl *gomock.Controller - recorder *MockiUpdaterMockRecorder[T] + recorder *MockIUpdaterMockRecorder[T] } -// MockiUpdaterMockRecorder is the mock recorder for MockiUpdater. -type MockiUpdaterMockRecorder[T any] struct { - mock *MockiUpdater[T] +// MockIUpdaterMockRecorder is the mock recorder for MockIUpdater. +type MockIUpdaterMockRecorder[T any] struct { + mock *MockIUpdater[T] } -// NewMockiUpdater creates a new mock instance. -func NewMockiUpdater[T any](ctrl *gomock.Controller) *MockiUpdater[T] { - mock := &MockiUpdater[T]{ctrl: ctrl} - mock.recorder = &MockiUpdaterMockRecorder[T]{mock} +// NewMockIUpdater creates a new mock instance. +func NewMockIUpdater[T any](ctrl *gomock.Controller) *MockIUpdater[T] { + mock := &MockIUpdater[T]{ctrl: ctrl} + mock.recorder = &MockIUpdaterMockRecorder[T]{mock} return mock } // EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockiUpdater[T]) EXPECT() *MockiUpdaterMockRecorder[T] { +func (m *MockIUpdater[T]) EXPECT() *MockIUpdaterMockRecorder[T] { return m.recorder } // UpdateMany mocks base method. -func (m *MockiUpdater[T]) UpdateMany(ctx context.Context, opts ...options.Lister[options.UpdateOptions]) (*mongo.UpdateResult, error) { +func (m *MockIUpdater[T]) UpdateMany(ctx context.Context, opts ...options.Lister[options.UpdateOptions]) (*mongo.UpdateResult, error) { m.ctrl.T.Helper() varargs := []any{ctx} for _, a := range opts { @@ -54,14 +54,14 @@ func (m *MockiUpdater[T]) UpdateMany(ctx context.Context, opts ...options.Lister } // UpdateMany indicates an expected call of UpdateMany. -func (mr *MockiUpdaterMockRecorder[T]) UpdateMany(ctx any, opts ...any) *gomock.Call { +func (mr *MockIUpdaterMockRecorder[T]) UpdateMany(ctx any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() varargs := append([]any{ctx}, opts...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateMany", reflect.TypeOf((*MockiUpdater[T])(nil).UpdateMany), varargs...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateMany", reflect.TypeOf((*MockIUpdater[T])(nil).UpdateMany), varargs...) } // UpdateOne mocks base method. -func (m *MockiUpdater[T]) UpdateOne(ctx context.Context, opts ...options.Lister[options.UpdateOptions]) (*mongo.UpdateResult, error) { +func (m *MockIUpdater[T]) UpdateOne(ctx context.Context, opts ...options.Lister[options.UpdateOptions]) (*mongo.UpdateResult, error) { m.ctrl.T.Helper() varargs := []any{ctx} for _, a := range opts { @@ -74,14 +74,14 @@ func (m *MockiUpdater[T]) UpdateOne(ctx context.Context, opts ...options.Lister[ } // UpdateOne indicates an expected call of UpdateOne. -func (mr *MockiUpdaterMockRecorder[T]) UpdateOne(ctx any, opts ...any) *gomock.Call { +func (mr *MockIUpdaterMockRecorder[T]) UpdateOne(ctx any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() varargs := append([]any{ctx}, opts...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateOne", reflect.TypeOf((*MockiUpdater[T])(nil).UpdateOne), varargs...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateOne", reflect.TypeOf((*MockIUpdater[T])(nil).UpdateOne), varargs...) } // Upsert mocks base method. -func (m *MockiUpdater[T]) Upsert(ctx context.Context, opts ...options.Lister[options.UpdateOptions]) (*mongo.UpdateResult, error) { +func (m *MockIUpdater[T]) Upsert(ctx context.Context, opts ...options.Lister[options.UpdateOptions]) (*mongo.UpdateResult, error) { m.ctrl.T.Helper() varargs := []any{ctx} for _, a := range opts { @@ -94,8 +94,8 @@ func (m *MockiUpdater[T]) Upsert(ctx context.Context, opts ...options.Lister[opt } // Upsert indicates an expected call of Upsert. -func (mr *MockiUpdaterMockRecorder[T]) Upsert(ctx any, opts ...any) *gomock.Call { +func (mr *MockIUpdaterMockRecorder[T]) Upsert(ctx any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() varargs := append([]any{ctx}, opts...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Upsert", reflect.TypeOf((*MockiUpdater[T])(nil).Upsert), varargs...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Upsert", reflect.TypeOf((*MockIUpdater[T])(nil).Upsert), varargs...) } diff --git a/updater/updater.go b/updater/updater.go index 77526fd..0120d12 100644 --- a/updater/updater.go +++ b/updater/updater.go @@ -30,7 +30,7 @@ import ( ) //go:generate mockgen -source=updater.go -destination=../mock/updater.mock.go -package=mocks -type iUpdater[T any] interface { +type IUpdater[T any] interface { UpdateOne(ctx context.Context, opts ...options.Lister[options.UpdateOptions]) (*mongo.UpdateResult, error) UpdateMany(ctx context.Context, opts ...options.Lister[options.UpdateOptions]) (*mongo.UpdateResult, error) Upsert(ctx context.Context, opts ...options.Lister[options.UpdateOptions]) (*mongo.UpdateResult, error) @@ -40,7 +40,7 @@ func NewUpdater[T any](collection *mongo.Collection) *Updater[T] { return &Updater[T]{collection: collection, filter: nil} } -var _ iUpdater[any] = (*Updater[any])(nil) +var _ IUpdater[any] = (*Updater[any])(nil) type Updater[T any] struct { collection *mongo.Collection diff --git a/updater/updater_test.go b/updater/updater_test.go index 0e2061b..2ca6425 100644 --- a/updater/updater_test.go +++ b/updater/updater_test.go @@ -32,7 +32,7 @@ func TestNewUpdater(t *testing.T) { func TestUpdater_UpdateOne(t *testing.T) { testCases := []struct { name string - mock func(ctx context.Context, ctl *gomock.Controller) iUpdater[any] + mock func(ctx context.Context, ctl *gomock.Controller) IUpdater[any] ctx context.Context want *mongo.UpdateResult @@ -40,8 +40,8 @@ func TestUpdater_UpdateOne(t *testing.T) { }{ { name: "failed to update one", - mock: func(ctx context.Context, ctl *gomock.Controller) iUpdater[any] { - updater := mocks.NewMockiUpdater[any](ctl) + mock: func(ctx context.Context, ctl *gomock.Controller) IUpdater[any] { + updater := mocks.NewMockIUpdater[any](ctl) updater.EXPECT().UpdateOne(ctx).Return(nil, assert.AnError).Times(1) return updater }, @@ -54,8 +54,8 @@ func TestUpdater_UpdateOne(t *testing.T) { }, { name: "execute successfully but modified count is 0", - mock: func(ctx context.Context, ctl *gomock.Controller) iUpdater[any] { - updater := mocks.NewMockiUpdater[any](ctl) + mock: func(ctx context.Context, ctl *gomock.Controller) IUpdater[any] { + updater := mocks.NewMockIUpdater[any](ctl) updater.EXPECT().UpdateOne(ctx).Return(&mongo.UpdateResult{ModifiedCount: 0}, nil).Times(1) return updater }, @@ -69,8 +69,8 @@ func TestUpdater_UpdateOne(t *testing.T) { }, { name: "update successfully", - mock: func(ctx context.Context, ctl *gomock.Controller) iUpdater[any] { - updater := mocks.NewMockiUpdater[any](ctl) + mock: func(ctx context.Context, ctl *gomock.Controller) IUpdater[any] { + updater := mocks.NewMockIUpdater[any](ctl) updater.EXPECT().UpdateOne(ctx).Return(&mongo.UpdateResult{ModifiedCount: 1}, nil).Times(1) return updater }, @@ -99,7 +99,7 @@ func TestUpdater_UpdateOne(t *testing.T) { func TestUpdater_UpdateMany(t *testing.T) { testCases := []struct { name string - mock func(ctx context.Context, ctl *gomock.Controller) iUpdater[any] + mock func(ctx context.Context, ctl *gomock.Controller) IUpdater[any] ctx context.Context want *mongo.UpdateResult @@ -107,8 +107,8 @@ func TestUpdater_UpdateMany(t *testing.T) { }{ { name: "failed to update many", - mock: func(ctx context.Context, ctl *gomock.Controller) iUpdater[any] { - updater := mocks.NewMockiUpdater[any](ctl) + mock: func(ctx context.Context, ctl *gomock.Controller) IUpdater[any] { + updater := mocks.NewMockIUpdater[any](ctl) updater.EXPECT().UpdateMany(ctx).Return(nil, assert.AnError).Times(1) return updater }, @@ -120,8 +120,8 @@ func TestUpdater_UpdateMany(t *testing.T) { }, { name: "execute successfully but modified count is 0", - mock: func(ctx context.Context, ctl *gomock.Controller) iUpdater[any] { - updater := mocks.NewMockiUpdater[any](ctl) + mock: func(ctx context.Context, ctl *gomock.Controller) IUpdater[any] { + updater := mocks.NewMockIUpdater[any](ctl) updater.EXPECT().UpdateMany(ctx).Return(&mongo.UpdateResult{ModifiedCount: 0}, nil).Times(1) return updater }, @@ -135,8 +135,8 @@ func TestUpdater_UpdateMany(t *testing.T) { }, { name: "update successfully", - mock: func(ctx context.Context, ctl *gomock.Controller) iUpdater[any] { - updater := mocks.NewMockiUpdater[any](ctl) + mock: func(ctx context.Context, ctl *gomock.Controller) IUpdater[any] { + updater := mocks.NewMockIUpdater[any](ctl) updater.EXPECT().UpdateMany(ctx).Return(&mongo.UpdateResult{ModifiedCount: 2}, nil).Times(1) return updater }, @@ -165,7 +165,7 @@ func TestUpdater_UpdateMany(t *testing.T) { func TestUpdater_Upsert(t *testing.T) { testCases := []struct { name string - mock func(ctx context.Context, ctl *gomock.Controller) iUpdater[any] + mock func(ctx context.Context, ctl *gomock.Controller) IUpdater[any] ctx context.Context want *mongo.UpdateResult @@ -173,8 +173,8 @@ func TestUpdater_Upsert(t *testing.T) { }{ { name: "failed to upsert one", - mock: func(ctx context.Context, ctl *gomock.Controller) iUpdater[any] { - updater := mocks.NewMockiUpdater[any](ctl) + mock: func(ctx context.Context, ctl *gomock.Controller) IUpdater[any] { + updater := mocks.NewMockIUpdater[any](ctl) updater.EXPECT().Upsert(ctx).Return(nil, assert.AnError).Times(1) return updater }, @@ -187,8 +187,8 @@ func TestUpdater_Upsert(t *testing.T) { }, { name: "save successfully", - mock: func(ctx context.Context, ctl *gomock.Controller) iUpdater[any] { - updater := mocks.NewMockiUpdater[any](ctl) + mock: func(ctx context.Context, ctl *gomock.Controller) IUpdater[any] { + updater := mocks.NewMockIUpdater[any](ctl) updater.EXPECT().Upsert(ctx).Return(&mongo.UpdateResult{UpsertedCount: 1}, nil).Times(1) return updater }, @@ -202,8 +202,8 @@ func TestUpdater_Upsert(t *testing.T) { }, { name: "update successfully", - mock: func(ctx context.Context, ctl *gomock.Controller) iUpdater[any] { - updater := mocks.NewMockiUpdater[any](ctl) + mock: func(ctx context.Context, ctl *gomock.Controller) IUpdater[any] { + updater := mocks.NewMockIUpdater[any](ctl) updater.EXPECT().Upsert(ctx).Return(&mongo.UpdateResult{ModifiedCount: 1}, nil).Times(1) return updater },