Documentation
¶
Index ¶
Constants ¶
const DBNameChars = "abcdefghijklmnopqrstuvwxyz"
DBNameChars is the set of characters used by RandomDatabase(). It's OK to change this, but not concurrently with calls to RandomDatabase.
const DBNameLen = 15
DBNameLen is the length of a database name generated by RandomDatabase(). It's OK to change this, but not concurrently with calls to RandomDatabase.
Variables ¶
This section is empty.
Functions ¶
func RandomDatabase ¶
func RandomDatabase() string
RandomDatabase returns a random valid mongo database name. You can use to to pick a new database name for each test to isolate tests from each other without having to tear down the whole server.
This function will panic if it cannot generate a random number.
Types ¶
type Options ¶
type Options struct { // Port to run MongoDB on. If this is not specified, a random (OS-assigned) // port will be used Port int // Path to the cache for downloaded mongod binaries. Defaults to the // system cache location. CachePath string // If DownloadURL and MongodBin are not given, this version of MongoDB will // be downloaded MongoVersion string // If given, mongod will be downloaded from this URL instead of the // auto-detected URL based on the current platform and MongoVersion DownloadURL string // If given, this binary will be run instead of downloading a mongod binary MongodBin string // Logger for printing messages. Defaults to printing to stdout. Logger *log.Logger // A LogLevel to log at. Defaults to LogLevelInfo. LogLevel memongolog.LogLevel // How long to wait for mongod to start up and report a port number. Does // not include download time, only startup time. Defaults to 10 seconds. StartupTimeout time.Duration }
Options is the configuration options for a launched MongoDB binary
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server represents a running MongoDB server
func Start ¶
Start runs a MongoDB server at a given MongoDB version using default options and returns the Server.
func StartWithOptions ¶
StartWithOptions is like Start(), but accepts options.
func (*Server) URIWithRandomDB ¶
URIWithRandomDB returns a mongodb:// URI to connect to, with a random database name (e.g. mongodb://localhost:1234/somerandomname)