diff --git a/index_view.go b/index_view.go index 13e4c97..428a5c4 100644 --- a/index_view.go +++ b/index_view.go @@ -15,6 +15,11 @@ type IndexView interface { CreateOne(ctx context.Context, model mongo.IndexModel, opts ...*options.CreateIndexesOptions) (string, error) DropAll(ctx context.Context, opts ...*options.DropIndexesOptions) (bson.Raw, error) DropOne(ctx context.Context, name string, opts ...*options.DropIndexesOptions) (bson.Raw, error) + DropOneWithKey( + ctx context.Context, + keySpecDocument interface{}, + opts ...*options.DropIndexesOptions, + ) (bson.Raw, error) List(ctx context.Context, opts ...*options.ListIndexesOptions) (Cursor, error) ListSpecifications(ctx context.Context, opts ...*options.ListIndexesOptions) ([]*mongo.IndexSpecification, error) } @@ -47,6 +52,14 @@ func (i *indexView) DropOne(ctx context.Context, name string, opts ...*options.D return i.iv.DropOne(ctx, name, opts...) } +func (i *indexView) DropOneWithKey( + ctx context.Context, + keySpecDocument interface{}, + opts ...*options.DropIndexesOptions, +) (bson.Raw, error) { + return i.iv.DropOneWithKey(ctx, keySpecDocument, opts...) +} + func (i *indexView) List(ctx context.Context, opts ...*options.ListIndexesOptions) (Cursor, error) { cr, err := i.iv.List(ctx, opts...) if err != nil { diff --git a/mocks/gomock/mocks.go b/mocks/gomock/mocks.go index 1184381..b68a40e 100644 --- a/mocks/gomock/mocks.go +++ b/mocks/gomock/mocks.go @@ -1470,6 +1470,26 @@ func (mr *MockIndexViewMockRecorder) DropOne(arg0, arg1 any, arg2 ...any) *gomoc return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DropOne", reflect.TypeOf((*MockIndexView)(nil).DropOne), varargs...) } +// DropOneWithKey mocks base method. +func (m *MockIndexView) DropOneWithKey(arg0 context.Context, arg1 any, arg2 ...*options.DropIndexesOptions) (bson.Raw, error) { + m.ctrl.T.Helper() + varargs := []any{arg0, arg1} + for _, a := range arg2 { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "DropOneWithKey", varargs...) + ret0, _ := ret[0].(bson.Raw) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// DropOneWithKey indicates an expected call of DropOneWithKey. +func (mr *MockIndexViewMockRecorder) DropOneWithKey(arg0, arg1 any, arg2 ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{arg0, arg1}, arg2...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DropOneWithKey", reflect.TypeOf((*MockIndexView)(nil).DropOneWithKey), varargs...) +} + // List mocks base method. func (m *MockIndexView) List(arg0 context.Context, arg1 ...*options.ListIndexesOptions) (mongoifc.Cursor, error) { m.ctrl.T.Helper() diff --git a/mocks/mockery/index_view.go b/mocks/mockery/index_view.go index 6fdf470..6c66b21 100644 --- a/mocks/mockery/index_view.go +++ b/mocks/mockery/index_view.go @@ -322,6 +322,80 @@ func (_c *IndexView_DropOne_Call) RunAndReturn(run func(context.Context, string, return _c } +// DropOneWithKey provides a mock function with given fields: ctx, keySpecDocument, opts +func (_m *IndexView) DropOneWithKey(ctx context.Context, keySpecDocument interface{}, opts ...*options.DropIndexesOptions) (bson.Raw, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, keySpecDocument) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for DropOneWithKey") + } + + var r0 bson.Raw + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, interface{}, ...*options.DropIndexesOptions) (bson.Raw, error)); ok { + return rf(ctx, keySpecDocument, opts...) + } + if rf, ok := ret.Get(0).(func(context.Context, interface{}, ...*options.DropIndexesOptions) bson.Raw); ok { + r0 = rf(ctx, keySpecDocument, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(bson.Raw) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, interface{}, ...*options.DropIndexesOptions) error); ok { + r1 = rf(ctx, keySpecDocument, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// IndexView_DropOneWithKey_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DropOneWithKey' +type IndexView_DropOneWithKey_Call struct { + *mock.Call +} + +// DropOneWithKey is a helper method to define mock.On call +// - ctx context.Context +// - keySpecDocument interface{} +// - opts ...*options.DropIndexesOptions +func (_e *IndexView_Expecter) DropOneWithKey(ctx interface{}, keySpecDocument interface{}, opts ...interface{}) *IndexView_DropOneWithKey_Call { + return &IndexView_DropOneWithKey_Call{Call: _e.mock.On("DropOneWithKey", + append([]interface{}{ctx, keySpecDocument}, opts...)...)} +} + +func (_c *IndexView_DropOneWithKey_Call) Run(run func(ctx context.Context, keySpecDocument interface{}, opts ...*options.DropIndexesOptions)) *IndexView_DropOneWithKey_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]*options.DropIndexesOptions, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(*options.DropIndexesOptions) + } + } + run(args[0].(context.Context), args[1].(interface{}), variadicArgs...) + }) + return _c +} + +func (_c *IndexView_DropOneWithKey_Call) Return(_a0 bson.Raw, _a1 error) *IndexView_DropOneWithKey_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *IndexView_DropOneWithKey_Call) RunAndReturn(run func(context.Context, interface{}, ...*options.DropIndexesOptions) (bson.Raw, error)) *IndexView_DropOneWithKey_Call { + _c.Call.Return(run) + return _c +} + // List provides a mock function with given fields: ctx, opts func (_m *IndexView) List(ctx context.Context, opts ...*options.ListIndexesOptions) (mongoifc.Cursor, error) { _va := make([]interface{}, len(opts))