The Forgejo runner doesn't expose /var/run/docker.sock, so anything relying on testcontainers-go panicked with "Cannot connect to the Docker daemon". This caused internal/testutils, tests/transactions and tests/integration to fail wholesale, plus internal/handlers to hit the 5min hard timeout while waiting for container startup. Approach (least invasive): - testutils.GetTestContainerDB short-circuits when VEZA_SKIP_INTEGRATION=1 is set, returning a sentinel error immediately instead of attempting three retries against a missing Docker socket. - Add testutils.SkipIfNoIntegration helper for granular per-test skips. - Add TestMain to internal/testutils, tests/transactions and tests/integration packages that os.Exit(0) when the env var is set, so the entire integration-only package is silently skipped in CI. - Wire the helper into the three setupTestDB* functions in tests/transactions/ for local runs (where TestMain doesn't fire when using -run on individual tests). Local nightly runs / dev workstations leave VEZA_SKIP_INTEGRATION unset and exercise the full suite against testcontainers as before.
23 lines
722 B
Go
23 lines
722 B
Go
package testutils
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
)
|
|
|
|
// SkipIfNoIntegration skips the current test when integration prerequisites
|
|
// (notably a running Docker daemon for testcontainers-go) are unavailable.
|
|
//
|
|
// It honors:
|
|
// - `go test -short` (testing.Short())
|
|
// - VEZA_SKIP_INTEGRATION=1 environment variable (set by CI runners
|
|
// without Docker socket access)
|
|
//
|
|
// Call this at the very top of any test helper that relies on
|
|
// GetTestContainerDB or otherwise spins up Postgres via testcontainers.
|
|
func SkipIfNoIntegration(t *testing.T) {
|
|
t.Helper()
|
|
if testing.Short() || os.Getenv("VEZA_SKIP_INTEGRATION") == "1" {
|
|
t.Skip("integration test requires Docker; skipped (-short or VEZA_SKIP_INTEGRATION=1)")
|
|
}
|
|
}
|