Documentation
¶
Index ¶
- Constants
- func LogPreconditionOverride(t *testing.T)
- func RequireAWSCredentials(t *testing.T)
- func RequireAWSProfile(t *testing.T, profileName string)
- func RequireAzureCredentials(t *testing.T)
- func RequireContainerRuntime(t *testing.T) string
- func RequireDocker(t *testing.T)
- func RequireEnvVar(t *testing.T, name string, purpose string)
- func RequireExecutable(t *testing.T, name string, purpose string)
- func RequireFilePath(t *testing.T, path string, purpose string)
- func RequireGitCommitConfig(t *testing.T)
- func RequireGitRemoteWithValidURL(t *testing.T) string
- func RequireGitRepository(t *testing.T) *git.Repository
- func RequireHelmfile(t *testing.T)
- func RequireNetworkAccess(t *testing.T, url string)
- func RequireOCIAuthentication(t *testing.T)
- func RequirePacker(t *testing.T)
- func RequirePodman(t *testing.T)
- func RequireTerraform(t *testing.T)
- func RequireTerraformOrTofu(t *testing.T)
- func RequireTerraformPath(t *testing.T) string
- func RequireTofu(t *testing.T)
- func RequireTofuPath(t *testing.T) string
- func ShouldCheckPreconditions() bool
- func SkipIfGomonkeyUnsafe(t testing.TB, reason string)
- func SkipIfShort(t *testing.T)
- func SkipIfTerraformRegistryError(t *testing.T, output string)
- func SkipOnDarwinARM64(t *testing.T, reason string)
- type GitHubRateLimitInfo
Constants ¶
const RaceEnabled = false
RaceEnabled is true when the test binary was built with -race. Used to skip tests that are safe under normal execution but incompatible with the race detector's instrumented binary layout, such as gomonkey's runtime machine-code patching (see SkipIfGomonkeyUnsafe).
Variables ¶
This section is empty.
Functions ¶
func LogPreconditionOverride ¶
LogPreconditionOverride logs when precondition checks are disabled.
func RequireAWSCredentials ¶ added in v1.198.0
RequireAWSCredentials checks if AWS credentials are available through any standard method. It uses the AWS SDK to validate that credentials can be loaded from environment variables, shared credentials file, EC2 instance metadata, or any other credential source.
func RequireAWSProfile ¶
RequireAWSProfile checks if AWS can be configured with the given profile. It uses the AWS SDK to validate that the profile can be loaded.
func RequireAzureCredentials ¶ added in v1.196.0
RequireAzureCredentials checks if Azure credentials appear to be configured. This function looks for common Azure credential sources: - Environment variables (AZURE_TENANT_ID, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET) - Azure CLI credentials (az login) Note: This does not validate that credentials are valid, only that they are present.
func RequireContainerRuntime ¶ added in v1.201.0
RequireContainerRuntime checks if a container runtime (Docker or Podman) is available. It prefers Docker but will accept Podman if Docker is not available. Returns the name of the available runtime ("docker" or "podman").
func RequireDocker ¶ added in v1.201.0
RequireDocker checks if Docker is available and running. Use this for tests that specifically require Docker (not Podman).
func RequireEnvVar ¶
RequireEnvVar checks if an environment variable is set.
func RequireExecutable ¶
RequireExecutable checks if an executable is available in PATH. Unlike requireExecutablePath, a bypass (ATMOS_TEST_SKIP_PRECONDITION_CHECKS=true) is a full no-op here: callers that only need a boolean gate, not the resolved path, don't need the tool to actually be resolvable when checks are disabled.
func RequireFilePath ¶
RequireFilePath checks if a file or directory exists.
func RequireGitCommitConfig ¶ added in v1.194.0
RequireGitCommitConfig checks if Git is configured for making commits. This checks for user.name and user.email configuration which are required for commits.
func RequireGitRemoteWithValidURL ¶
RequireGitRemoteWithValidURL checks for valid Git remotes that can be parsed.
func RequireGitRepository ¶
func RequireGitRepository(t *testing.T) *git.Repository
RequireGitRepository checks if we're in a valid Git repository.
func RequireHelmfile ¶ added in v1.194.0
RequireHelmfile checks if helmfile is installed and available in PATH. This is a convenience function that uses RequireExecutable specifically for helmfile.
func RequireNetworkAccess ¶
RequireNetworkAccess checks general network connectivity to a URL.
func RequireOCIAuthentication ¶
RequireOCIAuthentication checks if authentication is configured for GitHub API access. This is required for pulling OCI images from ghcr.io, cloning from github.com, and avoiding GitHub API rate limits. This is typically provided by GITHUB_TOKEN or ATMOS_GITHUB_TOKEN environment variables.
func RequirePacker ¶ added in v1.194.0
RequirePacker checks if packer is installed and available in PATH. This is a convenience function that uses RequireExecutable specifically for packer.
func RequirePodman ¶ added in v1.201.0
RequirePodman checks if Podman is available and running. Use this for tests that specifically require Podman (not Docker).
func RequireTerraform ¶ added in v1.194.0
RequireTerraform checks if terraform is installed and available in PATH. This is a convenience function that uses RequireExecutable specifically for terraform.
func RequireTerraformOrTofu ¶ added in v1.216.0
RequireTerraformOrTofu checks if terraform or tofu is installed and available in PATH. Use this for tests whose fixture atmos.yaml sets command: tofu, or that work with either binary.
func RequireTerraformPath ¶ added in v1.225.0
RequireTerraformPath is like RequireTerraform but also returns the resolved terraform binary path. Prefer this over calling RequireTerraform followed by a separate exec.LookPath("terraform") -- see requireExecutablePath's doc comment for why two independent lookups are unsafe.
func RequireTofu ¶ added in v1.222.0
RequireTofu checks if tofu (OpenTofu) is installed and available in PATH. The CLI test suite standardizes on OpenTofu (see ATMOS_COMPONENTS_TERRAFORM_COMMAND in cli_test.go), so terraform-invoking tests gate on this rather than terraform.
func RequireTofuPath ¶ added in v1.225.0
RequireTofuPath is like RequireTofu but also returns the resolved tofu binary path. Prefer this over calling RequireTofu followed by a separate exec.LookPath("tofu") -- see requireExecutablePath's doc comment for why two independent lookups are unsafe.
func ShouldCheckPreconditions ¶
func ShouldCheckPreconditions() bool
ShouldCheckPreconditions returns true if precondition checks should be performed. Set ATMOS_TEST_SKIP_PRECONDITION_CHECKS=true to bypass all precondition checks.
func SkipIfGomonkeyUnsafe ¶ added in v1.228.0
SkipIfGomonkeyUnsafe skips the test on darwin/arm64 (SIGBUS from memory protection, see SkipOnDarwinARM64) and under -race (a separate, equally fatal incompatibility: gomonkey overwrites a target function's machine code with a jump instruction, sized for that function's normal compiled layout, but the race detector's instrumentation changes that layout, making the patch corrupt the function -- observed in CI as the patched call hanging indefinitely rather than erroring, taking the whole package's `go test -race` run down with it once the package-level -timeout fires). Use this instead of an inline runtime.GOARCH check for any test calling gomonkey.ApplyFunc/NewPatches. Accepts testing.TB so it also works from Benchmark functions, not just Test functions. SkipIfGomonkeyUnsafe is intentionally NOT gated by ShouldCheckPreconditions either, matching SkipOnDarwinARM64: both incompatibilities are hard crashes in the current process, not a missing external dependency CI can supply.
func SkipIfShort ¶ added in v1.194.0
SkipIfShort skips the test if running in short mode (go test -short). Use this for tests that take more than 2 seconds (network I/O, heavy processing, Git operations, etc.).
func SkipIfTerraformRegistryError ¶ added in v1.222.0
SkipIfTerraformRegistryError skips the test when the captured Terraform/OpenTofu output shows a transient provider-registry failure (for example, an HTTP 429 rate limit from registry.terraform.io). These failures are environmental, not regressions, so the repo treats them as skips, mirroring the Packer init network-failure handling. Pass the captured command output (stdout/stderr) collected while running the Terraform subcommand.
func SkipOnDarwinARM64 ¶ added in v1.195.0
SkipOnDarwinARM64 skips the test if running on darwin/arm64 (macOS ARM). Use this for tests that are incompatible with ARM64 macOS, such as tests using gomonkey which causes fatal SIGBUS errors due to memory protection on ARM64. SkipOnDarwinARM64 is intentionally NOT gated by ShouldCheckPreconditions/ ATMOS_TEST_SKIP_PRECONDITION_CHECKS, unlike other precondition checks in this file: that env var exists so CI can force tests to run despite a missing local dependency (Docker, network, credentials) that CI does have. It cannot make gomonkey safe on darwin/arm64 -- CI sets that env var for exactly the acceptance-test jobs that also run on macOS, so honoring it here would defeat this check's entire purpose on the one platform it exists to protect.
Types ¶
type GitHubRateLimitInfo ¶
GitHubRateLimitInfo contains GitHub API rate limit information.
func RequireGitHubAccess ¶
func RequireGitHubAccess(t *testing.T) *GitHubRateLimitInfo
RequireGitHubAccess checks network connectivity and rate limits for GitHub.