Documentation
¶
Overview ¶
Package testutil provides shared test utilities for integration tests.
Package testutil provides shared test utilities for integration tests.
Index ¶
Constants ¶
const ( PostgresImage = "postgres:15.13-alpine@sha256:1414298ea93186123a6dcf872f778ba3bd2347edcbd2f31aa7bb2d9814ff5393" RedisImage = "redis:7.4.2-alpine@sha256:02419de7eddf55aa5bcf49efb74e88fa8d931b4d77c07eff8a6b2144472b6952" RabbitMQImage = "rabbitmq:3.12.14-management-alpine@sha256:0b44fbcc3a4bf22d00090f1353127577dbe1fcb109c41669733a9d7ecf6c3a78" VaultImage = "hashicorp/vault:1.17@sha256:74a4ab138ab5d64725e89cd9a9c73f7040c7fe49e98b71697b275ca9a69919df" OTelCollectorImage = "otel/opentelemetry-collector:0.123.0@sha256:e5e4a13f0ea98e7ca1d1d809be040180540146888d0d764abd4e1277cba87350" // K3sImage pins the rancher/k3s single-node Kubernetes image used by the // Vault Kubernetes-auth e2e (adapters/vault/k8s_auth_e2e_integration_test.go). // Version v1.27.1-k3s1 matches the default of testcontainers-go // modules/k3s v0.42.0 (k3s.RunContainer); the @sha256 digest is the // authoritative pin (manifest-list digest from // `docker buildx imagetools inspect rancher/k3s:v1.27.1-k3s1`). K3sImage = "rancher/k3s:v1.27.1-k3s1@sha256:b1b1e98ea5776124d74d8a68151b1eeb3a6f15d8bd596a88ac0d5c36d78b3ede" // MinIOImage pins the MinIO server image by content digest. MinIO upstream // uses ISO timestamp release tags (RELEASE.YYYY-MM-DDTHH-MM-SSZ) that don't // fit SemVer patterns; the tag segment matches the upstream release cadence // (verified from image labels: release="RELEASE.2025-09-07T16-13-09Z") and // the @sha256 digest is the immutable content reference and authoritative pin. MinIOImage = "minio/minio:RELEASE.2025-09-07T16-13-09Z@sha256:14cea493d9a34af32f524e538b8346cf79f3321eff8e708c1e2960462bd8936e" // MosquittoImage is the eclipse-mosquitto v2.0.22 MQTT broker image pinned by digest. // Used by adapters/mqtt integration tests. // Patch version confirmed via `docker image inspect eclipse-mosquitto:2.0 .Config.Labels["org.opencontainers.image.version"]`. MosquittoImage = "eclipse-mosquitto:2.0.22@sha256:914f529386804c8278a4e581526b9be5e1604df44b30daabc70aa97dcefe5268" )
Testcontainer images pinned to specific patch versions and immutable digests. Floating minor tags (e.g., "postgres:15-alpine") and tag-only patch pins are forbidden because they cause non-reproducible CI builds when upstream retags.
Update procedure: bump the patch version, refresh the manifest-list digest for the exact tag, run `go test ./tests/testutil/...` to verify the format, then run integration tests.
const RedisClusterTestAddrsEnv = "GOCELL_TEST_REDIS_CLUSTER_ADDRS"
RedisClusterTestAddrsEnv is the discovery env consumed by adapters/redis/cluster_real_test.go (build tag `integration_cluster`). The test reads this variable at runtime and skips when unset rather than spawning a 6-node cluster from inside the Go test process — testcontainers-go has no cluster module and grokzen/redis-cluster requires host-mode networking which Mac/Windows do not support reliably. Operators run the cluster out-of-band (see docs/ops/redis-cluster-deployment.md) and export this variable before invoking the test.
Variables ¶
This section is empty.
Functions ¶
func LoopbackIPEndpoint ¶
LoopbackIPEndpoint rewrites testcontainer endpoints that use localhost to 127.0.0.1 so plaintext endpoint validation still receives an IP literal.
func RequireDocker ¶
RequireDocker skips t if Docker is not available in a local test environment. Integration tests that use testcontainers must call this at the top of the test (or setup helper) so local runs self-skip when Docker is unavailable.
Accepts both *testing.T and *testing.B so setup helpers shared between unit tests and benchmarks can use the same guard without a wrapper.
Set GOCELL_TEST_DOCKER_REQUIRED=1 in CI jobs where Docker-backed integration tests are mandatory. In that mode an unavailable provider is a test failure, not a skip, so CI cannot go green without executing the integration path.
Types ¶
This section is empty.