Documentation ¶
Overview ¶
Package db is a generated GoMock package.
Index ¶
- Variables
- func ExpectFindOneError(coll *MockMongoCollection, err error, times int)
- func ExpectInsertOne(coll *MockMongoCollection, times int)
- func ExpectInsertOneError(coll *MockMongoCollection, err error, times int)
- func ExpectUpdateOneError(coll *MockMongoCollection, err error, times int)
- func Get(ctx ...interface{}) (*mongo.Database, error)
- func IsDbTimeoutError(err interface{})
- func IsDbUniqueKeyError(err error) bool
- type Cursor
- type MockCursor
- type MockCursorMockRecorder
- type MockMongoCollection
- func (m *MockMongoCollection) EXPECT() *MockMongoCollectionMockRecorder
- func (m *MockMongoCollection) Find(ctx context.Context, filter interface{}) (Cursor, error)
- func (m *MockMongoCollection) FindOne(ctx context.Context, filter, v interface{}) error
- func (m *MockMongoCollection) InsertOne(ctx context.Context, document interface{}) (interface{}, error)
- func (m *MockMongoCollection) UpdateOne(ctx context.Context, filter, update interface{}) (int64, error)
- type MockMongoCollectionMockRecorder
- func (mr *MockMongoCollectionMockRecorder) Find(ctx, filter interface{}) *gomock.Call
- func (mr *MockMongoCollectionMockRecorder) FindOne(ctx, filter, v interface{}) *gomock.Call
- func (mr *MockMongoCollectionMockRecorder) InsertOne(ctx, document interface{}) *gomock.Call
- func (mr *MockMongoCollectionMockRecorder) UpdateOne(ctx, filter, update interface{}) *gomock.Call
- type MongoCollection
Constants ¶
This section is empty.
Variables ¶
var TestIsUniqueError = mongo.WriteException{ WriteErrors: []mongo.WriteError{ { Code: 11000, }, }, }
Mock Data
var TestOtherDbError = mongo.WriteException{ WriteErrors: []mongo.WriteError{ { Code: 1, }, }, }
Functions ¶
func ExpectFindOneError ¶
func ExpectFindOneError(coll *MockMongoCollection, err error, times int)
Espect common functions
func ExpectInsertOne ¶
func ExpectInsertOne(coll *MockMongoCollection, times int)
func ExpectInsertOneError ¶
func ExpectInsertOneError(coll *MockMongoCollection, err error, times int)
func ExpectUpdateOneError ¶
func ExpectUpdateOneError(coll *MockMongoCollection, err error, times int)
func IsDbTimeoutError ¶
func IsDbTimeoutError(err interface{})
IsDbTimeoutError función a llamar cuando se produce un error de db
func IsDbUniqueKeyError ¶
IsDbUniqueKeyError retorna true si el error es de indice único
Types ¶
type Cursor ¶
type Cursor interface { Close(ctx context.Context) error Next(ctx context.Context) bool Decode(val interface{}) error }
func NewMongoCursor ¶
type MockCursor ¶
type MockCursor struct {
// contains filtered or unexported fields
}
MockCursor is a mock of Cursor interface.
func NewMockCursor ¶
func NewMockCursor(ctrl *gomock.Controller) *MockCursor
NewMockCursor creates a new mock instance.
func (*MockCursor) Close ¶
func (m *MockCursor) Close(ctx context.Context) error
Close mocks base method.
func (*MockCursor) Decode ¶
func (m *MockCursor) Decode(val interface{}) error
Decode mocks base method.
func (*MockCursor) EXPECT ¶
func (m *MockCursor) EXPECT() *MockCursorMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
type MockCursorMockRecorder ¶
type MockCursorMockRecorder struct {
// contains filtered or unexported fields
}
MockCursorMockRecorder is the mock recorder for MockCursor.
func (*MockCursorMockRecorder) Close ¶
func (mr *MockCursorMockRecorder) Close(ctx interface{}) *gomock.Call
Close indicates an expected call of Close.
func (*MockCursorMockRecorder) Decode ¶
func (mr *MockCursorMockRecorder) Decode(val interface{}) *gomock.Call
Decode indicates an expected call of Decode.
func (*MockCursorMockRecorder) Next ¶
func (mr *MockCursorMockRecorder) Next(ctx interface{}) *gomock.Call
Next indicates an expected call of Next.
type MockMongoCollection ¶
type MockMongoCollection struct {
// contains filtered or unexported fields
}
MockMongoCollection is a mock of MongoCollection interface.
func NewMockMongoCollection ¶
func NewMockMongoCollection(ctrl *gomock.Controller) *MockMongoCollection
NewMockMongoCollection creates a new mock instance.
func (*MockMongoCollection) EXPECT ¶
func (m *MockMongoCollection) EXPECT() *MockMongoCollectionMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockMongoCollection) Find ¶
func (m *MockMongoCollection) Find(ctx context.Context, filter interface{}) (Cursor, error)
Find mocks base method.
func (*MockMongoCollection) FindOne ¶
func (m *MockMongoCollection) FindOne(ctx context.Context, filter, v interface{}) error
FindOne mocks base method.
type MockMongoCollectionMockRecorder ¶
type MockMongoCollectionMockRecorder struct {
// contains filtered or unexported fields
}
MockMongoCollectionMockRecorder is the mock recorder for MockMongoCollection.
func (*MockMongoCollectionMockRecorder) Find ¶
func (mr *MockMongoCollectionMockRecorder) Find(ctx, filter interface{}) *gomock.Call
Find indicates an expected call of Find.
func (*MockMongoCollectionMockRecorder) FindOne ¶
func (mr *MockMongoCollectionMockRecorder) FindOne(ctx, filter, v interface{}) *gomock.Call
FindOne indicates an expected call of FindOne.
func (*MockMongoCollectionMockRecorder) InsertOne ¶
func (mr *MockMongoCollectionMockRecorder) InsertOne(ctx, document interface{}) *gomock.Call
InsertOne indicates an expected call of InsertOne.
func (*MockMongoCollectionMockRecorder) UpdateOne ¶
func (mr *MockMongoCollectionMockRecorder) UpdateOne(ctx, filter, update interface{}) *gomock.Call
UpdateOne indicates an expected call of UpdateOne.
type MongoCollection ¶
type MongoCollection interface { FindOne(ctx context.Context, filter interface{}, v interface{}) error InsertOne(ctx context.Context, document interface{}) (id interface{}, error error) UpdateOne(ctx context.Context, filter interface{}, update interface{}) (modified int64, error error) Find(ctx context.Context, filter interface{}) (cur Cursor, err error) }
func NewMongoCollection ¶
func NewMongoCollection(collection *mongo.Collection) MongoCollection