mgo

package module
v0.0.0-...-32cbea1 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2020 License: MIT Imports: 7 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = mgo.ErrNotFound
	ErrCursor   = mgo.ErrCursor
)

Functions

This section is empty.

Types

type Collectioner

type Collectioner interface {
	Count() (n int, err error)
	Create(info *mgo.CollectionInfo) error
	DropCollection() error
	DropIndex(key ...string) error
	DropIndexName(name string) error
	EnsureIndex(index mgo.Index) error
	EnsureIndexKey(key ...string) error
	Find(query interface{}) Querier
	FindId(id interface{}) Querier
	Indexes() (indexes []mgo.Index, err error)
	Insert(docs ...interface{}) error
	NewIter(session *mgo.Session, firstBatch []bson.Raw, cursorId int64, err error) Iterator
	Pipe(pipeline interface{}) *mgo.Pipe
	Remove(selector interface{}) error
	RemoveId(id interface{}) error
	RemoveAll(selector interface{}) (info *mgo.ChangeInfo, err error)
	Repair() Iterator
	Update(selector interface{}, update interface{}) error
	UpdateId(id interface{}, update interface{}) error
	UpdateAll(selector interface{}, update interface{}) (info *mgo.ChangeInfo, err error)
	Upsert(selector interface{}, update interface{}) (info *mgo.ChangeInfo, err error)
	UpsertId(id interface{}, update interface{}) (info *mgo.ChangeInfo, err error)
	With(s *mgo.Session) Collectioner

	MethodCalls() []methodCall
}

Collectioner is the public interface for *mgo.Collection to enable mocking

type Databaser

type Databaser interface {
	AddUser(username, password string, readOnly bool) error
	C(name string) Collectioner
	CollectionNames() (names []string, err error)
	DropDatabase() error
	FindRef(ref *mgo.DBRef) Querier
	GridFS(prefix string) *mgo.GridFS
	Login(user, pass string) error
	Logout()
	RemoveUser(user string) error
	Run(cmd interface{}, result interface{}) error
	UpsertUser(user *mgo.User) error
	With(s *mgo.Session) Databaser
}

Databaser is the public interface for *mgo.Database to enable mocking

type FakeMongoQuery

type FakeMongoQuery struct {
	DB         string
	Collection string
	Query      interface{}
	Return     interface{}
}

FakeMongoQuery is a struct which holds return values for queries

type Iterator

type Iterator interface {
	Err() error
	Done() bool
	Close() error
	Next(result interface{}) bool
	All(result interface{}) error
}

Iterator is the public interface for *mgo.Iter to enable mocking

type Piper

type Piper interface {
	AllowDiskUse() Piper
	Batch(n int) Piper
	Iter() Iterator
	All(result interface{}) error
	One(result interface{}) error
	Explain(result interface{}) error
}

Piper is the public interface for *mgo.Pipe to enable mocking

type Querier

type Querier interface {
	All(result interface{}) error
	Apply(change mgo.Change, result interface{}) (info *mgo.ChangeInfo, err error)
	Batch(n int) Querier
	Comment(comment string) Querier
	Count() (n int, err error)
	Distinct(key string, result interface{}) error
	Explain(result interface{}) error
	Hint(indexKey ...string) Querier
	Iter() Iterator
	Limit(n int) Querier
	LogReplay() Querier
	MapReduce(job *mgo.MapReduce, result interface{}) (info *mgo.MapReduceInfo, err error)
	One(result interface{}) (err error)
	Prefetch(p float64) Querier
	Select(selector interface{}) Querier
	SetMaxScan(n int) Querier
	SetMaxTime(d time.Duration) Querier
	Snapshot() Querier
	Sort(fields ...string) Querier
	Skip(n int) Querier
	Tail(timeout time.Duration) Iterator
}

Querier is the public interface for *mgo.Query to enable mocking

type Sessioner

type Sessioner interface {
	BuildInfo() (info mgo.BuildInfo, err error)
	Clone() Sessioner
	Close()
	Copy() Sessioner
	DatabaseNames() (names []string, err error)
	DB(name string) Databaser
	EnsureSafe(safe *mgo.Safe)
	FindRef(ref *mgo.DBRef) Querier
	Fsync(async bool) error
	FsyncLock() error
	FsyncUnlock() error
	LiveServers() (addrs []string)
	Login(cred *mgo.Credential) error
	LogoutAll()
	Mode() mgo.Mode
	New() Sessioner
	Ping() error
	Refresh()
	ResetIndexCache()
	Run(cmd interface{}, result interface{}) error
	Safe() (safe *mgo.Safe)
	SelectServers(tags ...bson.D)
	SetBatch(n int)
	SetBypassValidation(bypass bool)
	SetCursorTimeout(d time.Duration)
	SetMode(consistency mgo.Mode, refresh bool)
	SetPoolLimit(limit int)
	SetPrefetch(p float64)
	SetSafe(safe *mgo.Safe)
	SetSocketTimeout(d time.Duration)
	SetSyncTimeout(d time.Duration)
}

Sessioner is the public interface for *mgo.Session to enable mocking

func Dial

func Dial(url string) (Sessioner, error)

Dial is a light wrapper over mgo.Dial(url) function to enable mocking

func NewFakeSession

func NewFakeSession(queryResults []FakeMongoQuery) (Sessioner, error)

NewFakeSession creates a fake mgo.Sessioner for mocking purposes

Jump to

Keyboard shortcuts

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