go-tstr / tstr / dep / container
github.com/go-tstr/tstr/dep/container
go get github.com/go-tstr/tstr/dep/container@v0.2.5
Overview
Package container provides a wrapper around the testcontainers-go library to simplify container management in tests.
Constants
const (
ErrCreateWithModule = strerr.Error("failed to create container with testcontainers module")
ErrCreateWithGenericContainer = strerr.Error("failed to create generic container")
)Types
type Container
type Container struct {
// contains filtered or unexported fields
}func New
func New(opts ...Opt) *Containerfunc (*Container) Container
func (c *Container) Container() testcontainers.ContainerContainer returns the underlying testcontainers.Container.
func (*Container) Ready
func (c *Container) Ready() errorfunc (*Container) Start
func (c *Container) Start() errorfunc (*Container) Stop
func (c *Container) Stop() errortype Opt
type Opt func(*Container) errorfunc WithGenericContainer
func WithGenericContainer(req testcontainers.GenericContainerRequest) OptWithGenericContainer creates a container using the testcontainers.GenericContainer function.
func WithModule
func WithModule[T testcontainers.Container](
runFn func(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (T, error),
img string,
opts ...testcontainers.ContainerCustomizer,
) OptWithModule creates a container using the testcontainers-go modules.
func WithReadyFn
func WithReadyFn(fn func(testcontainers.Container) error) OptWithReadyFn sets a custom readiness function which should block until ready.