helpers

package
v0.0.0-...-2300dd9 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTestImage

func GetTestImage(defaultImage string) string

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

func RequireFileExists(t *testing.T, image string, filePath string)

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

type HTTPTestConfig

type HTTPTestConfig struct {
	Port       string
	Path       string
	StatusCode int
	Timeout    time.Duration // optional startup timeout for the HTTP wait strategy (0 = library default)
}

HTTPTestConfig holds the configuration for HTTP endpoint tests

Jump to

Keyboard shortcuts

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