Documentation ¶
Overview ¶
Package mongo includes mongo implementation of Gnomock Preset interface. This Preset can be passed to gnomock.StartPreset function to create a configured mongo container to use in tests
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Option ¶
type Option func(*P)
Option is an optional configuration of this Gnomock preset. Use available Options to configure the container.
func WithData ¶
WithData sets up initial container state according to the directory structure at the given path:
- path/first/one
- path/first/two
- path/second/three
For such directory structure, two databases are created: "first" and "second". Under "first" database there are two collections, "one" and "two", and under "second" database - one collection "three".
Files "one", "two" and "three" are text files with JSON documents to be inserted into the database. One line should include one document.
Top level files under "path" are ignored, only directories are used. Similarly, directories located anywhere besides top-level "path", are also ignored.
func WithUser ¶
WithUser creates a root user with the provided name and password. This user should be used as a part of mongodb connection string. If you choose not to use your own user and password, the databases will be unprotected, and you won't need to specify any name and password in your connection string.
func WithVersion ¶ added in v0.9.0
WithVersion sets image version.
type P ¶
type P struct { DataPath string `json:"data_path"` User string `json:"user"` Password string `json:"password"` Version string `json:"version"` }
P is a Gnomock Preset implementation of MongoDB.
func (*P) Ports ¶
func (p *P) Ports() gnomock.NamedPorts
Ports returns ports that should be used to access this container.