testingdb

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

func MustRun

func MustRun(t *testing.T, name string, fn func(*testing.T, *mongo.Database))

MustRun creates a test using the given name. A new mongo.Database will be created against the TestingDB.container using the given name. The new test simply runs fn injecting the new mongo.Database.

If a database cannot be created, t.Fatal is called.

func Run

func Run(t *testing.T, name string, fn func(*testing.T, *mongo.Database)) error

Run creates a test using the given name. A new mongo.Database will be created against the TestingDB.container using the given name. The new test simply runs fn injecting the new mongo.Database.

Returns an error if a database cannot be created.

func RunWithDatabase

func RunWithDatabase(t *testing.T, name string, db *mongo.Database, fn func(*testing.T, *mongo.Database))

RunWithDatabase creates a test using the given database's name. The new test simply runs fn injecting db. Use this function if you need to customize the database with custom options.

func Setup

func Setup(req mc.ContainerRequest) error

func TearDown

func TearDown() error

TearDown performs clean up operations such as stopping the container.

Types

type TestingDB

type TestingDB struct {
	// contains filtered or unexported fields
}

TestingDB - An object to store the container reference.

func NewTestDB

func NewTestDB(req mc.ContainerRequest) (*TestingDB, error)

NewTestDB provides an entry point for you to config the mongo container.

func (*TestingDB) MustRun

func (tdb *TestingDB) MustRun(t *testing.T, name string, fn func(*testing.T, *mongo.Database))

MustRun creates a test using the given name. A new mongo.Database will be created against the TestingDB.container using the given name. The new test simply runs fn injecting the new mongo.Database.

If a database cannot be created, t.Fatal is called.

func (*TestingDB) Run

func (tdb *TestingDB) Run(t *testing.T, name string, fn func(*testing.T, *mongo.Database)) error

Run creates a test using the given name. A new mongo.Database will be created against the TestingDB.container using the given name. The new test simply runs fn injecting the new mongo.Database.

Returns an error if a database cannot be created.

func (*TestingDB) TearDown

func (tdb *TestingDB) TearDown() error

TearDown performs clean up operations such as stopping the container.

Jump to

Keyboard shortcuts

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