Documentation
¶
Index ¶
- Constants
- func BuildExternalConnectionString(ctx context.Context, container testcontainers.Container, opts ...MongoOption) (string, error)
- func BuildInternalConnectionString(ctx context.Context, container testcontainers.Container, opts ...MongoOption) (string, error)
- func WithMongoContainer() container.ContainerOption
- type MongoOption
- type Options
Constants ¶
const ( ExposedPort string = "27017" User string = "mongo" Pass string = "mongo" )
Variables ¶
This section is empty.
Functions ¶
func BuildExternalConnectionString ¶ added in v1.1.0
func BuildExternalConnectionString(ctx context.Context, container testcontainers.Container, opts ...MongoOption) (string, error)
Return a MongoDB connection string for the given container with default options when the container is NOT in a network
Example: "mongodb://mongo:mongo@localhost:27017/"
func BuildInternalConnectionString ¶ added in v1.1.0
func BuildInternalConnectionString(ctx context.Context, container testcontainers.Container, opts ...MongoOption) (string, error)
Return a MongoDB connection string for the given container with default options when the container is in a network
Example: "mongodb://mongo:mongo@network_alias:27017/"
func WithMongoContainer ¶
func WithMongoContainer() container.ContainerOption
Return a new container definition for a MongoDB container with default options
DockerImage: "mongo:7" Exposed ports: "27017" Environment variables: MONGO_INITDB_ROOT_USERNAME: "mongo" MONGO_INITDB_ROOT_PASSWORD: "mongo" WaitingForLog: "Waiting for connections" StartupTimeout: "30 seconds"
Types ¶
type MongoOption ¶
type MongoOption func(*Options)
MongoOption is a type that represents a MongoDB option
func WithExposedPort ¶
func WithExposedPort(exposedPort string) MongoOption
WithExposedPort is a MongoOption that sets the exposed port of the MongoDB container
Default: "27017"
func WithNetwork ¶ added in v1.1.0
func WithNetwork(network *network.Network) MongoOption
WithNetwork is a MongoOption that sets the network alias of the MongoDB container
Default: nil
func WithPass ¶
func WithPass(pass string) MongoOption
WithPass is a MongoOption that sets the password of the MongoDB container
Default: "test"
func WithUser ¶
func WithUser(user string) MongoOption
WithUser is a MongoOption that sets the user of the MongoDB container
Default: "test"