db

package
v0.0.0-...-a705f4d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 10, 2024 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package db is a generated GoMock package.

Index

Constants

This section is empty.

Variables

View Source
var TestIsUniqueError = mongo.WriteException{
	WriteErrors: []mongo.WriteError{
		{
			Code: 11000,
		},
	},
}

Mock Data

View Source
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 Get

func Get(ctx ...interface{}) (*mongo.Database, error)

Get the mongo database

func IsDbTimeoutError

func IsDbTimeoutError(err interface{})

IsDbTimeoutError función a llamar cuando se produce un error de db

func IsDbUniqueKeyError

func IsDbUniqueKeyError(err error) bool

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

func NewMongoCursor(cursor *mongo.Cursor) Cursor

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.

func (*MockCursor) Next

func (m *MockCursor) Next(ctx context.Context) bool

Next mocks base method.

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

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.

func (*MockMongoCollection) InsertOne

func (m *MockMongoCollection) InsertOne(ctx context.Context, document interface{}) (interface{}, error)

InsertOne mocks base method.

func (*MockMongoCollection) UpdateOne

func (m *MockMongoCollection) UpdateOne(ctx context.Context, filter, update interface{}) (int64, error)

UpdateOne 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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL