Documentation
¶
Index ¶
- func GetTestImage(defaultImage string) string
- func RequireCommandSucceeds(t *testing.T, image string, config *ContainerConfig, entrypoint string, ...)
- func RequireDaemonStartsUp(t *testing.T, image string, daemonConfig DaemonStartupConfig, ...)
- func RequireFileExists(t *testing.T, image string, filePath string)
- func RequireHTTPEndpoint(t *testing.T, image string, httpConfig HTTPTestConfig, ...)
- type ContainerConfig
- type DaemonStartupConfig
- type FileToCopy
- type HTTPTestConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetTestImage ¶
GetTestImage returns the image to test from TEST_IMAGE env var or falls back to the default
func RequireCommandSucceeds ¶
func RequireCommandSucceeds(t *testing.T, image string, config *ContainerConfig, entrypoint string, args ...string)
RequireCommandSucceeds tests that a command runs successfully in the container (exit code 0)
func RequireDaemonStartsUp ¶
func RequireDaemonStartsUp(t *testing.T, image string, daemonConfig DaemonStartupConfig, containerConfig *ContainerConfig)
RequireDaemonStartsUp starts a long-running daemon container using the image's own ENTRYPOINT/CMD (or overrides from containerConfig), waits for a log line matching LogPattern to prove it reached a healthy running state, and then asserts the container is still running.
func RequireFileExists ¶
RequireFileExists tests that a file exists in the image by inspecting its filesystem directly, without starting the container. Works for images with no shell or executables.
func RequireHTTPEndpoint ¶
func RequireHTTPEndpoint(t *testing.T, image string, httpConfig HTTPTestConfig, containerConfig *ContainerConfig)
RequireHTTPEndpoint tests that an HTTP endpoint is accessible and returns the expected status code
Types ¶
type ContainerConfig ¶
type ContainerConfig struct {
Env map[string]string // Environment variables to set in the container
Files []FileToCopy // Host files to place in the container before it starts
Tmpfs map[string]string // Tmpfs mounts, keyed by container path, valued by mount options (e.g. "rw,mode=1777")
}
ContainerConfig holds optional container configuration
type DaemonStartupConfig ¶
type DaemonStartupConfig struct {
LogPattern string // Regexp the container's stdout/stderr must match to prove it reached a healthy running state.
Timeout time.Duration // Startup timeout for LogPattern to appear; 0 uses the wait library's default (60s).
}
DaemonStartupConfig holds the configuration for testing a long-running daemon container.
type FileToCopy ¶
type FileToCopy struct {
HostPath string // Path on the host, relative to the test's package directory
ContainerPath string // Absolute destination path inside the container
Mode int64 // File mode; defaults to 0o644 when zero
}
FileToCopy describes a host file to place inside the container