mongo

package
v0.0.0-...-b7fba14 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDatabaseMock

func NewDatabaseMock(coll mongo.Collection) mongo.Database

func NewStorageMock

func NewStorageMock(uri string, client mongo.Client) *mongo.Storage

Types

type ClientMock

type ClientMock struct {
	DB           mongo.Database
	ConnectErr   error
	DisconectErr error
	PingErr      error
}

func NewClientMock

func NewClientMock(db mongo.Database, connectErr error, disconnectErr error, pingErr error) *ClientMock

func (*ClientMock) Connect

func (m *ClientMock) Connect(ctx context.Context) error

func (*ClientMock) Database

func (m *ClientMock) Database(databaseName string) mongo.Database

func (*ClientMock) Disconnect

func (m *ClientMock) Disconnect(ctx context.Context) error

func (*ClientMock) Ping

func (m *ClientMock) Ping(ctx context.Context, readpref *readpref.ReadPref) error

type CollectionMock

type CollectionMock struct {
	Value interface{}
	Err   error
}

func NewCollectionMock

func NewCollectionMock(value interface{}, err error) *CollectionMock

func (*CollectionMock) Count

func (m *CollectionMock) Count(ctx context.Context, filter interface{}) (int64, error)

func (*CollectionMock) Find

func (m *CollectionMock) Find(ctx context.Context, filter interface{}, opts ...*options.FindOptions) (mongo.Cursor, error)

func (*CollectionMock) FindOne

func (m *CollectionMock) FindOne(ctx context.Context, filter interface{}) mongo.SingleResult

func (*CollectionMock) InsertOne

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

type CursorMock

type CursorMock struct {
	Cursor  int
	Current interface{}
	Values  interface{}
	Error   error
	// contains filtered or unexported fields
}

func NewCursorMock

func NewCursorMock(values interface{}, err error) *CursorMock

func (*CursorMock) Close

func (m *CursorMock) Close(ctx context.Context) error

func (*CursorMock) Decode

func (m *CursorMock) Decode(v interface{}) error

func (*CursorMock) Err

func (m *CursorMock) Err() error

func (*CursorMock) Len

func (m *CursorMock) Len() int64

func (*CursorMock) Next

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

type DatabaseMock

type DatabaseMock struct {
	Coll mongo.Collection
}

func (*DatabaseMock) Collection

func (m *DatabaseMock) Collection(name string) mongo.Collection

type SingleResultMock

type SingleResultMock mocks.Mock

func (*SingleResultMock) Decode

func (m *SingleResultMock) Decode(v interface{}) error

type StorageMock

type StorageMock mongo.Storage

func (*StorageMock) WithCollection

func (m *StorageMock) WithCollection(collection *CollectionMock) *StorageMock

func (*StorageMock) WithDatabase

func (m *StorageMock) WithDatabase(database *DatabaseMock) *StorageMock

Jump to

Keyboard shortcuts

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