mongodb

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
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"

type Options

type Options struct {
	ExposedPort  string
	User         string
	Pass         string
	NetworkAlias *string
}

Options is a type that represents the options for a MongoDB container

Default options:
	ExposedPort: "27017"
	User: "mongo"
	Pass: "mongo"

Jump to

Keyboard shortcuts

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