testcontainermongo

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2022 License: Apache-2.0, Unlicense Imports: 4 Imported by: 0

README

Mongo testcontainer

A mongo docker testcontainer for go

Example usage:

initPath, err := filepath.Abs("./fixtures")
if err != nil {
    log.Fatalf("%v", err)
}
ctx := context.Background()
container, conn, err := mongotestcontainer.New(ctx, "latest", initPath)
if err != nil {
    log.Fatalf("%v", err)
}
defer Terminate(ctx, container)

fmt.Println(conn)
// Output: mongodb://root:example@localhost:49156/test_db

Run tests

sh go test

Documentation

Overview

Package testcontainermongo provides an easy way to start a mongo testcontainer using docker

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(ctx context.Context, tag, init string) (testcontainers.Container, string, error)

New setup a mongo testcontainer

func Terminate

func Terminate(ctx context.Context, c testcontainers.Container)

Terminate terminates the container in a defer friendly way

Types

This section is empty.

Jump to

Keyboard shortcuts

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