package integrationtest // import "git.griefed.de/griefed/repoman/internal/integrationtest"
Package integrationtest provides helpers shared by repoman's live integration
tests — the ones that talk to a real Forgejo, GitHub, GitLab, Gitea, or SMTP
server rather than to httptest fakes.
These tests are OPT-IN and double-gated:
1. They do nothing unless REPOMAN_INTEGRATION=1 is set (Require).
2. Each test additionally skips when the specific connection detail it needs is
absent from the environment (Env).
This keeps the test files COMPILED during the default `go test ./...` (so they
cannot silently rot and stay under every lint/vet gate) while never running —
and never reaching the network — unless an operator has explicitly switched them
on and supplied real endpoints. The alternative, a //go:build integration tag,
would exclude the files from the default build and therefore from go vet /
staticcheck / errcheck unless every gate were re-run with the tag.
CONSTANTS
const SwitchVar = "REPOMAN_INTEGRATION"
SwitchVar is the master opt-in environment variable. Set it to "1" to allow
the integration tests to run; leave it unset for everyday testing.
FUNCTIONS
func Enabled() bool
Enabled reports whether the integration suite is switched on. Useful for
TestMain-style early exits; individual tests should prefer Require.
func Env(t *testing.T, key string) string
Env returns the value of the named environment variable, skipping (not
failing) the calling test when it is unset or empty. A skip — rather than a
fatal — is correct here: an operator who only has GitHub credentials should
be able to run the GitHub integration test without the GitLab one turning
the suite red.
func EnvDefault(key, def string) string
EnvDefault returns the named variable's value, or def when it is unset or
empty. Use it for optional knobs (TLS mode, owner type) that have a sensible
default rather than gating the test.
func Flag(key string) bool
Flag reports whether the named environment variable is exactly "1". Used to
gate the destructive opt-ins (real-write migration, actually-deliver email)
so they stay off unless deliberately enabled.
func Require(t *testing.T)
Require skips the calling test unless the master switch is on. It is the
first line of every integration test, so a default `go test ./...` reports
them as skipped rather than failing on missing infrastructure.