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

testenv

package
v1.0.316 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package testenv gates tests that need external fixtures, such as the local-kms emulator or the SoftHSM token (XPKI-100).

A fixture that is not reachable skips the test, unless XPKI_INTEGRATION is "required" (the Makefile exports it, so make test/covtest and CI fail instead). A reachable fixture always runs the test, so a present but broken fixture fails. Unit tests must not call it.

func TestKMS(t *testing.T) {
	testenv.RequireTCP(t, "local-kms", "localhost:14556")
	// ...
}

RequireFile does the same for a fixture identified by a file, such as the SoftHSM token configuration.

Index

Constants

View Source
const (
	// IntegrationEnv is the environment variable that selects whether a
	// missing fixture skips or fails a test.
	IntegrationEnv = "XPKI_INTEGRATION"
	// Required is the IntegrationEnv value that makes a missing fixture fail.
	Required = "required"
)

Variables

This section is empty.

Functions

func IntegrationRequired

func IntegrationRequired() bool

IntegrationRequired reports whether a missing fixture must fail the test.

func RequireFile

func RequireFile(t testing.TB, name, path string)

RequireFile gates t on the fixture name whose file is at path, such as the SoftHSM token configuration. It returns when path exists. Otherwise it fails t when IntegrationRequired, and skips t when not. Any stat error other than a missing file fails t, since the fixture is present but broken.

func RequireTCP

func RequireTCP(t testing.TB, name, addr string)

RequireTCP gates t on the fixture name listening at addr ("host:port"). It returns when addr accepts a TCP connection. Otherwise it fails t when IntegrationRequired, and skips t when not.

Types

This section is empty.

Jump to

Keyboard shortcuts

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