mongodbcontainer

package
v0.0.0-...-6f4c623 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Container

type Container struct {
	Con tc.Container
	// contains filtered or unexported fields
}

func NewContainer

func NewContainer(ctx context.Context, req ContainerRequest) (mc *Container, err error)

NewContainer creates an instance testcontainers.Container configured to run mongo:tag. By default, i.e, passing an empty req, the Con is configured with the mongo:latest image, port 27017, a default user "user" with password "password". To override any of these options see ContainerRequest.

func (*Container) ConnectionURI

func (c *Container) ConnectionURI() (str string, err error)

func (*Container) NewClient

func (c *Container) NewClient() (*mongo.Client, error)

NewClient creates a new mongo client using the connection string of the Container. The connection is tested once before returning the new client.

func (*Container) NewDatabase

func (c *Container) NewDatabase(name string, opts ...*options.DatabaseOptions) (*mongo.Database, error)

NewDatabase creates a new mongo client then a new database with then given name and options.

func (*Container) Start

func (c *Container) Start() error

func (*Container) Stop

func (c *Container) Stop() error

type ContainerRequest

type ContainerRequest struct {
	tc.GenericContainerRequest
	User     string
	Password string
}

Jump to

Keyboard shortcuts

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