Help us shape the future of Go! Take the 2026 Go Developer Survey

containertest

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package containertest gates the tests that start containers (decision 0015). They need a Docker daemon that runs Linux containers: GitHub's Windows runners have a healthy Docker that runs only Windows containers, so testcontainers' own health check passes and every Linux image then fails to start. Those tests skip there and run on Linux and on macOS with Docker Desktop.

Index

Constants

View Source
const (
	// MinIOImage is Chainguard's build of MinIO: MinIO stopped publishing
	// minio/minio on Docker Hub and its quay.io images need credentials.
	MinIOImage = "cgr.dev/chainguard/minio@sha256:" +
		"dc455cdd4db6e390b1b26514f15ff37681a777bf8dab41aac445a0259f751e56"
	// FakeGCSImage is fake-gcs-server 1.56.1.
	FakeGCSImage = "fsouza/fake-gcs-server:1.56.1@sha256:" +
		"797ce226d62f947c009dc40246b30cfb456b8473d8241407f9d6f2c04e4d69ef"
	// AzuriteImage is Azurite 3.37.0, the first release with Put Block From
	// URL. Its baseline API version is older than the one the Azure SDK
	// sends, so it runs with --skipApiVersionCheck (research 18).
	AzuriteImage = "mcr.microsoft.com/azure-storage/azurite@sha256:" +
		"830430c1da1a2d537e08f3e6764dd1f5ae00cf0346bcaf625b968ec3f0971fd5"
)

The emulator images are pinned by digest so an emulator release cannot change behaviour under the suites; bump them deliberately, here only.

View Source
const AnswerTimeout = 5 * time.Second

AnswerTimeout is how long the Docker engine has to answer before the tests that need it skip. A working engine answers in milliseconds, a CI runner's included. Docker Desktop on macOS can accept connections on its socket and then never answer (#458); testcontainers' own calls take no deadline there, so without this bound every Docker-backed test blocked until the package's -timeout killed the binary and hid every other result in it.

Variables

This section is empty.

Functions

func CheckLinux

func CheckLinux(ctx context.Context) error

CheckLinux returns an error unless a Docker daemon that runs Linux containers answers within AnswerTimeout, for callers without a *testing.T. The first call's answer holds for the rest of the test binary: an engine that did not answer once is not waited on again by every later test, and one that did is not asked again.

func FakeGCS

func FakeGCS(t *testing.T) string

FakeGCS starts fake-gcs-server for t and returns its JSON API endpoint, ending in "/storage/v1/" as the Cloud Storage client's option.WithEndpoint needs. It skips t where Docker cannot run Linux containers.

func RequireLinux

func RequireLinux(t *testing.T)

RequireLinux skips t unless a Docker daemon that runs Linux containers answers and the run is not -short.

func RunFakeGCS

func RunFakeGCS(ctx context.Context) (string, func(), error)

RunFakeGCS starts fake-gcs-server and returns its JSON API endpoint, as FakeGCS does, and a function that removes it, for callers without a *testing.T such as acceptance steps; check CheckLinux first.

Types

type AzuriteEndpoint

type AzuriteEndpoint struct {
	// ServiceURL is the account URL with a trailing slash. Its host is an IP
	// address: the Azure SDK treats a non-IP host as virtual-hosted style,
	// and Azurite is path style.
	ServiceURL string
	Account    string
	Key        string
}

AzuriteEndpoint addresses Azurite's blob service.

func Azurite

func Azurite(t *testing.T) AzuriteEndpoint

Azurite starts Azurite's blob service for t, or skips t where Docker cannot run Linux containers.

func RunAzurite

func RunAzurite(ctx context.Context) (AzuriteEndpoint, func(), error)

RunAzurite starts Azurite's blob service and returns its endpoint and a function that removes it, for callers without a *testing.T such as acceptance steps; check CheckLinux first.

type MinIOEndpoint

type MinIOEndpoint struct {
	// URL is the S3 endpoint, for example "http://127.0.0.1:32768"; MinIO
	// needs path-style addressing.
	URL      string
	User     string
	Password string
}

MinIOEndpoint addresses a MinIO server.

func MinIO

func MinIO(t *testing.T) MinIOEndpoint

MinIO starts MinIO for t, or skips t where Docker cannot run Linux containers.

func RunMinIO

func RunMinIO(ctx context.Context) (MinIOEndpoint, func(), error)

RunMinIO starts MinIO and returns its endpoint and a function that removes it, for callers without a *testing.T such as acceptance steps; check CheckLinux first.

Jump to

Keyboard shortcuts

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