Documentation ¶
Overview ¶
Package testcontainers provides extra functionalities for testcontainers-go.
Index ¶
- Variables
- func StopGenericContainers(ctx context.Context, containers ...Container) error
- type Container
- type ContainerCallback
- type ContainerRequest
- type ContainerStatus
- type GenericContainerOption
- func WithCallback(f ContainerCallback) GenericContainerOption
- func WithImageName(name string) GenericContainerOption
- func WithImageTag(tag string) GenericContainerOption
- func WithNamePrefix(prefix string) GenericContainerOption
- func WithNameSuffix(suffix string) GenericContainerOption
- func WithProviderType(providerType testcontainers.ProviderType) GenericContainerOption
- type StartGenericContainerRequest
Constants ¶
This section is empty.
Variables ¶
var PopulateHostPortEnv = ContainerCallback(func(ctx context.Context, c Container, r ContainerRequest) error { ports, err := c.Ports(ctx) if err != nil { return fmt.Errorf("could not get container %q ports: %w", r.Name, err) } if len(ports) == 0 { return nil } ip, err := c.Host(ctx) if err != nil { return fmt.Errorf("could not get container %q ip: %w", r.Name, err) } for p, bindings := range ports { for _, b := range bindings { if err := setEnvVar(r.Name, p, "HOST", ip); err != nil { return err } if err := setEnvVar(r.Name, p, "PORT", b.HostPort); err != nil { return err } } } return nil })
PopulateHostPortEnv sets the hostname and public port for each exposed port.
Functions ¶
Types ¶
type Container ¶
type Container = testcontainers.Container
Container is an alias of testcontainers.Container to avoid extra import.
func StartGenericContainer ¶
func StartGenericContainer(ctx context.Context, request ContainerRequest, opts ...GenericContainerOption) (Container, error)
StartGenericContainer starts a new generic container.
func StartGenericContainers ¶
func StartGenericContainers(ctx context.Context, requests ...StartGenericContainerRequest) (containers []Container, _ error)
StartGenericContainers starts multiple generic containers at once.
type ContainerCallback ¶
type ContainerCallback func(ctx context.Context, c Container, r ContainerRequest) error
ContainerCallback is called after a container is successfully created and started.
type ContainerRequest ¶
type ContainerRequest = testcontainers.ContainerRequest
ContainerRequest is an alias of testcontainers.ContainerRequest to avoid extra import.
type ContainerStatus ¶
type ContainerStatus string
ContainerStatus is status of a container.
const ( ContainerStatusCreated ContainerStatus = "created" ContainerStatusRunning ContainerStatus = "running" ContainerStatusPaused ContainerStatus = "paused" ContainerStatusRestarting ContainerStatus = "restarting" ContainerStatusRemoving ContainerStatus = "removing" ContainerStatusExited ContainerStatus = "exited" ContainerStatusDead ContainerStatus = "dead" )
Container statuses.
func (ContainerStatus) Equal ¶
func (s ContainerStatus) Equal(target string) bool
Equal checks if two statuses are the same.
type GenericContainerOption ¶
type GenericContainerOption interface {
// contains filtered or unexported methods
}
GenericContainerOption is option for starting a new generic container.
func WithCallback ¶
func WithCallback(f ContainerCallback) GenericContainerOption
WithCallback adds a new callback to run after the container is ready.
func WithImageName ¶
func WithImageName(name string) GenericContainerOption
WithImageName sets the image name.
func WithImageTag ¶
func WithImageTag(tag string) GenericContainerOption
WithImageTag sets the image tag.
func WithNamePrefix ¶
func WithNamePrefix(prefix string) GenericContainerOption
WithNamePrefix sets a prefix for the request name.
func WithNameSuffix ¶
func WithNameSuffix(suffix string) GenericContainerOption
WithNameSuffix sets a suffix for the request name.
func WithProviderType ¶
func WithProviderType(providerType testcontainers.ProviderType) GenericContainerOption
WithProviderType sets the provider type.
type StartGenericContainerRequest ¶
type StartGenericContainerRequest struct { Request ContainerRequest Options []GenericContainerOption }
StartGenericContainerRequest is request for starting a new generic container.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package mock provides functionalities for mocking testcontainers-go.
|
Package mock provides functionalities for mocking testcontainers-go. |
wait
Package wait provides functionalities for mocking testcontainers-go/wait.
|
Package wait provides functionalities for mocking testcontainers-go/wait. |
Package wait provides strategies for checking if a container is ready.
|
Package wait provides strategies for checking if a container is ready. |