Documentation
¶
Index ¶
- func DestroyGroup(ctx context.Context, group GroupContainer) (context.Context, error)
- func GetMappedPort(ctx context.Context, container testcontainers.Container, exposedPort nat.Port) (nat.Port, error)
- func NewGroup() map[string]GroupContainer
- type Container
- type ContainerOption
- func WithDockerfile(fromDockerFile testcontainers.FromDockerfile) ContainerOption
- func WithEnvVars(envVars map[string]string) ContainerOption
- func WithExecutableFiles(basePath string, files ...string) ContainerOption
- func WithExposedPorts(ports ...string) ContainerOption
- func WithFiles(basePath string, files ...string) ContainerOption
- func WithForceWaitDuration(duration time.Duration) ContainerOption
- func WithImage(image string) ContainerOption
- func WithNetwork(alias string, network *testcontainers.DockerNetwork) ContainerOption
- func WithWaitingForLog(log string, startupTimeout time.Duration) ContainerOption
- func WithWaitingForPort(port string, startupTimeout time.Duration) ContainerOption
- type GroupContainer
- type TestContainersOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DestroyGroup ¶
DestroyGroup destroys the given group of containers and the network (if exists)
func GetMappedPort ¶
func NewGroup ¶
func NewGroup() map[string]GroupContainer
NewGroup creates a new map of test contexts to store a group of containers
Types ¶
type Container ¶
type Container struct {
ContainerRequest testcontainers.ContainerRequest
ForceWaitDuration *time.Duration
}
Container is a type that represents a container that will be created
func NewContainerDefinition ¶
func NewContainerDefinition(opts ...ContainerOption) *Container
NewContainerDefinition creates a new container definition that will be used to create a container
func (*Container) BuildContainer ¶
BuildContainer creates a new container following the container definition
type ContainerOption ¶
type ContainerOption func(*Container)
ContainerOption is a type that represents a container option
func WithDockerfile ¶
func WithDockerfile(fromDockerFile testcontainers.FromDockerfile) ContainerOption
WithDockerfile is a ContainerOption that sets the Dockerfile data of the container
Default: nil
func WithEnvVars ¶
func WithEnvVars(envVars map[string]string) ContainerOption
WithEnvVars is a ContainerOption that sets the environment variables of the container
Default:
POSTGRES_DB: postgres_db POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres
func WithExecutableFiles ¶
func WithExecutableFiles(basePath string, files ...string) ContainerOption
WithExecutableFiles is a ContainerOption that sets the executable files of the container that will be copied to the container
Default: nil
func WithExposedPorts ¶
func WithExposedPorts(ports ...string) ContainerOption
WithExposedPorts is a ContainerOption that sets the exposed ports of the container
Default: 5432
func WithFiles ¶
func WithFiles(basePath string, files ...string) ContainerOption
WithFiles is a ContainerOption that sets the startup files of the container that will be copied to the container
Default: nil
func WithForceWaitDuration ¶
func WithForceWaitDuration(duration time.Duration) ContainerOption
WithForceWaitDuration is a ContainerOption that sets the duration to wait for the container to be ready
Default: nil
func WithImage ¶
func WithImage(image string) ContainerOption
WithImage is a ContainerOption that sets the image of the container
Default: postgres:latest
func WithNetwork ¶
func WithNetwork(alias string, network *testcontainers.DockerNetwork) ContainerOption
WithNetwork is a ContainerOption that sets the network of the container
Default: nil
func WithWaitingForLog ¶
func WithWaitingForLog(log string, startupTimeout time.Duration) ContainerOption
WithWaitingForLog is a ContainerOption that sets the log to wait for
Default: ready for start up
func WithWaitingForPort ¶
func WithWaitingForPort(port string, startupTimeout time.Duration) ContainerOption
WithWaitingForPort is a ContainerOption that sets the port to wait for
Example: "8080" for 30 seconds
type GroupContainer ¶
type GroupContainer struct {
Network *testcontainers.DockerNetwork
Containers []testcontainers.Container
}
GroupContainer is a type that represents a test context
func BuildGroupContainer ¶
func BuildGroupContainer(opts ...TestContainersOption) GroupContainer
BuildGroupContainer creates a new test context with the given options
type TestContainersOption ¶
type TestContainersOption func(*GroupContainer)
TestContainersOption is a type that represents a test context option
func WithDockerContainer ¶
func WithDockerContainer(container ...testcontainers.Container) TestContainersOption
WithDockerContainer is a TestContainersOption that sets the containers of the test context
func WithDockerNetwork ¶
func WithDockerNetwork(network *testcontainers.DockerNetwork) TestContainersOption
WithDockerNetwork is a TestContainersOption that sets the network of the test context