Documentation
¶
Index ¶
- Variables
- func SetupNetwork(ctx context.Context, pool dockertest.Pool, cleanIfExists bool) error
- func TCPPort(port int) network.Port
- type GoalStateVerifier
- type Image
- type Resource
- func (c *Resource) Close() error
- func (c *Resource) Closed() bool
- func (c *Resource) Exec(commands ...string) (string, error)
- func (c *Resource) GetPort(bindPort int) (int, error)
- func (c *Resource) GetURL(port int, path string) string
- func (c *Resource) GoalStateExec(verifier GoalStateVerifier, commands ...string) error
- func (c *Resource) Resource() dockertest.Resource
- type ResourceOptions
Constants ¶
This section is empty.
Variables ¶
var ( // ErrClosed is a common error for use when a container has been closed. ErrClosed = errors.New("container has been closed") )
Functions ¶
func SetupNetwork ¶
SetupNetwork sets up a network within docker.
Types ¶
type GoalStateVerifier ¶
GoalStateVerifier asserts that a resource is in a particular state. TODO: more info here; this interface is unclear from usage
type Resource ¶
type Resource struct {
// contains filtered or unexported fields
}
Resource is an object that provides a handle to a service being spun up via docker.
func NewDockerResource ¶
func NewDockerResource( ctx context.Context, pool dockertest.Pool, resourceOpts ResourceOptions, ) (*Resource, error)
NewDockerResource creates a new DockerResource. If resourceOpts.Image is empty, it will attempt to connect to an existing container. Otherwise, it will start the container with the specified image.
func (*Resource) GoalStateExec ¶
func (c *Resource) GoalStateExec( verifier GoalStateVerifier, commands ...string, ) error
GoalStateExec runs commands within a container until a specified goal state is met.
func (*Resource) Resource ¶
func (c *Resource) Resource() dockertest.Resource
Resource is the underlying dockertest resource used by this Resource. It can be used to perform more advanced operations not exposed by this class.
type ResourceOptions ¶
type ResourceOptions struct {
OverrideDefaults bool
Source string
ContainerName string
Image Image
PortList []int
PortMappings network.PortMap
// NoNetworkOverlay if set, disables use of the default integration testing network we create (networkName).
NoNetworkOverlay bool
Cmd []string
// Env is the environment for the docker container; it is passed through to dockertest.WithEnv.
// Format should be: VAR=value
Env []string
// Mounts creates mounts in the container that map back to a resource
// on the host system.
Mounts []string
// TmpfsMounts creates mounts to the container's temporary file system
TmpfsMounts []string
InstrumentOpts instrument.Options
}
ResourceOptions returns options for creating a Resource.
func (ResourceOptions) WithDefaults ¶
func (o ResourceOptions) WithDefaults( defaultOpts ResourceOptions) ResourceOptions
NB: this will fill unset fields with given default values.