mock

package
v0.0.0-...-91518e1 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2020 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	CollectionFn      CollectionFunc
	CollectionInvoked bool
}

Client is a mock implementation of database.Client.

func ClientMock

func ClientMock(srValue interface{}, srDecodeErr error, insertOneID interface{}) Client

ClientMock returns a basic mock for the entire database.

func (Client) Collection

func (c Client) Collection(name string) database.Collection

Collection returns a Collection mock and marks the function as invoked.

type Collection

type Collection struct {
	FindOneFn      FindOneFunc
	FindOneInvoked bool

	InsertOneFn      func(ctx context.Context, document interface{}, opts ...*options.InsertOneOptions) (interface{}, error)
	InsertOneInvoked bool
}

Collection is a mock implementation of database.Collection.

func (Collection) FindOne

func (c Collection) FindOne(ctx context.Context, filter interface{}, opts ...*options.FindOneOptions) database.SingleResult

FindOne invokes the mock implementation and marks the function as invoked.

func (Collection) InsertOne

func (c Collection) InsertOne(ctx context.Context, document interface{}, opts ...*options.InsertOneOptions) (interface{}, error)

InsertOne invokes the mock implementation and marks the function as invoked.

type CollectionFunc

type CollectionFunc func(name string) database.Collection

CollectionFunc is the function signature for Collection.

type FindOneFunc

type FindOneFunc func(ctx context.Context, filter interface{}, opts ...*options.FindOneOptions) database.SingleResult

FindOneFunc is the function signature for FindOne.

type SingleResult

type SingleResult struct {
	DecodeFn      func(v interface{}) error
	DecodeInvoked bool
}

SingleResult is a mock implementation of database.SingleResult.

func (SingleResult) Decode

func (sr SingleResult) Decode(v interface{}) error

Decode will unmarshal the document represented by this SingleResult into v.

Jump to

Keyboard shortcuts

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