definition

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const ContainerFileMode = 0o755
View Source
const DefaultLogProductionTimeout = 10 * time.Second
View Source
const HostNetworkingMode = "host"

Variables

This section is empty.

Functions

Types

type ContainerOption

type ContainerOption func(req *ContainerOpts)

ContainerOption is a type that can be used to configure the container creation request.

func WithCredential

func WithCredential(credential string) ContainerOption

WithCredential allows to set the credential to use for testing.

func WithDependancies

func WithDependancies(dependancies ...DependancyConn) ContainerOption

WithDependancies allows to set the dependancies to use for testing.

func WithEnableLogging

func WithEnableLogging(enableLogging bool) ContainerOption

WithEnableLogging allows to enable logging to use for testing.

func WithEnvironment

func WithEnvironment(environment map[string]string) ContainerOption

WithEnvironment allows to set the environment to use for testing.

func WithImageName

func WithImageName(imageName string) ContainerOption

WithImageName allows to set the image name to use for testing.

func WithLoggingTimeout

func WithLoggingTimeout(loggingTimeout time.Duration) ContainerOption

WithLoggingTimeout allows to set the logging timeout to use for testing.

func WithNetworkAliases

func WithNetworkAliases(networkAliases []string) ContainerOption

WithNetworkAliases allows to set the network aliases to use for testing.

func WithPorts

func WithPorts(ports ...string) ContainerOption

WithPorts allows to set the ports to use for testing.

func WithUseHostMode

func WithUseHostMode(useHostMode bool) ContainerOption

WithUseHostMode allows to set the use host mode to use for testing.

func WithUserName

func WithUserName(userName string) ContainerOption

WithUserName allows to set the user name to use for testing.

type ContainerOpts

type ContainerOpts struct {
	ImageName  string
	UserName   string
	Credential string

	Ports []string

	UseHostMode    bool
	NetworkAliases []string

	Environment  map[string]string
	Dependencies []DependancyConn

	EnableLogging  bool
	LoggingTimeout time.Duration
}

func (*ContainerOpts) ConfigurationExtend

func (o *ContainerOpts) ConfigurationExtend(
	ctx context.Context,
	ntwk *testcontainers.DockerNetwork,
	containerCustomize ...testcontainers.ContainerCustomizer,
) []testcontainers.ContainerCustomizer

func (*ContainerOpts) Configure

func (o *ContainerOpts) Configure(
	ctx context.Context,
	ntwk *testcontainers.DockerNetwork,
	containerRequest *testcontainers.ContainerRequest,
)

func (*ContainerOpts) Env

func (o *ContainerOpts) Env(defaultMap map[string]string) map[string]string

func (*ContainerOpts) Setup

func (o *ContainerOpts) Setup(opts ...ContainerOption)

type DefaultImpl

type DefaultImpl struct {
	DefaultScheme string
	DefaultPort   string
	// contains filtered or unexported fields
}

func NewDefaultImpl

func NewDefaultImpl(opts ContainerOpts, scheme string, containerOpts ...ContainerOption) *DefaultImpl

func (*DefaultImpl) Cleanup

func (d *DefaultImpl) Cleanup(ctx context.Context)

func (*DefaultImpl) ConfigurationExtend

func (d *DefaultImpl) ConfigurationExtend(
	ctx context.Context,
	ntwk *testcontainers.DockerNetwork,
	containerCustomize ...testcontainers.ContainerCustomizer,
) []testcontainers.ContainerCustomizer

func (*DefaultImpl) Configure

func (d *DefaultImpl) Configure(
	ctx context.Context,
	ntwk *testcontainers.DockerNetwork,
	containerRequest *testcontainers.ContainerRequest,
)

func (*DefaultImpl) Container

func (d *DefaultImpl) Container() testcontainers.Container

func (*DefaultImpl) Endpoint

func (d *DefaultImpl) Endpoint(ctx context.Context, scheme string, port string) (data.DSN, error)

func (*DefaultImpl) GetDS

func (d *DefaultImpl) GetDS(ctx context.Context) data.DSN

func (*DefaultImpl) GetInternalDS

func (d *DefaultImpl) GetInternalDS(ctx context.Context) data.DSN

func (*DefaultImpl) GetRandomisedDS

func (d *DefaultImpl) GetRandomisedDS(
	ctx context.Context,
	_ string,
) (data.DSN, func(context.Context), error)

func (*DefaultImpl) InternalEndpoint

func (d *DefaultImpl) InternalEndpoint(ctx context.Context, scheme string, port string) (data.DSN, error)

func (*DefaultImpl) Name

func (d *DefaultImpl) Name() string

func (*DefaultImpl) Opts

func (d *DefaultImpl) Opts() *ContainerOpts

func (*DefaultImpl) PortMapping

func (d *DefaultImpl) PortMapping(ctx context.Context, port string) (string, error)

func (*DefaultImpl) SetContainer

func (d *DefaultImpl) SetContainer(container testcontainers.Container)

type DependancyConn

type DependancyConn interface {
	Name() string
	PortMapping(ctx context.Context, port string) (string, error)
	GetDS(ctx context.Context) data.DSN
	GetInternalDS(ctx context.Context) data.DSN
	GetRandomisedDS(ctx context.Context, randomisedPrefix string) (data.DSN, func(context.Context), error)
}

type DependancyRes

type DependancyRes interface {
	Name() string
	Setup(ctx context.Context, network *testcontainers.DockerNetwork) error
	Cleanup(ctx context.Context)
	Container() testcontainers.Container
}

type DependencyOption

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

func NewDependancyOption

func NewDependancyOption(name string, prefix string, deps []DependancyConn) *DependencyOption

func (*DependencyOption) All

func (opt *DependencyOption) All() []DependancyConn

func (*DependencyOption) ByImageName

func (opt *DependencyOption) ByImageName(imageName string) DependancyConn

func (*DependencyOption) ByIsCache

func (opt *DependencyOption) ByIsCache(ctx context.Context) DependancyConn

func (*DependencyOption) ByIsDatabase

func (opt *DependencyOption) ByIsDatabase(ctx context.Context) DependancyConn

func (*DependencyOption) ByIsQueue

func (opt *DependencyOption) ByIsQueue(ctx context.Context) DependancyConn

func (*DependencyOption) Name

func (opt *DependencyOption) Name() string

func (*DependencyOption) Prefix

func (opt *DependencyOption) Prefix() string

type StdoutLogConsumer

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

func (*StdoutLogConsumer) Accept

func (s *StdoutLogConsumer) Accept(l testcontainers.Log)

Accept prints the log to stdout.

type TestResource

type TestResource interface {
	DependancyRes
	DependancyConn
}

Jump to

Keyboard shortcuts

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