Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrDisabled = errgo.New("MongoDB testing is disabled")
Functions ¶
This section is empty.
Types ¶
type Database ¶
type Database struct { *mgo.Database // contains filtered or unexported fields }
func New ¶
New connects to a MongoDB instance and returns a database instance that uses it. The database name is randomly chosen; all collections in the database will be removed when Close is called.
The environment variable MGOCONNECTIONSTRING will be consulted to determine the connection string to use (see https://docs.mongodb.com/manual/reference/connection-string/ or https://godoc.org/github.com/juju/mgo/v2#Dial for details of the format).
If MGOCONNECTIONSTRING is empty, "localhost" will be used.
If the environment variable MGOTESTDISABLE is non-empty, an error with a cause of ErrDisabled will be returned.
func NewExclusive ¶
NewExclusive is like New except that it always returns a session is freshly created, rather than using one that's shared with other tests.