testutil

package
v0.69.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package testutil provides shared helpers for graith's Go tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GitCommand

func GitCommand(args ...string) *exec.Cmd

GitCommand constructs a Git command with GitEnv applied.

func GitEnv

func GitEnv(overrides ...string) []string

GitEnv returns a deterministic environment for Git fixture commands. Every inherited GIT_* variable is stripped so host settings cannot redirect the repository, worktree, index, object database, config, SSH command, or hooks. SSH_AUTH_SOCK is also omitted: local-only fixtures never need credentials and must not contact a developer's agent. Optional KEY=value entries override the defaults, which is useful for tests that intentionally exercise --global config with a throwaway HOME.

func IsolateGit

func IsolateGit(t testing.TB)

IsolateGit applies GitEnv to the current test process so production helpers invoked in-process (rather than through GitCommand) are hermetic too. Tests using this helper must not run in parallel because environment variables are process-global.

func RunWithIsolatedGit

func RunWithIsolatedGit(m *testing.M) int

RunWithIsolatedGit runs a package's tests with the same hermetic Git environment used by GitCommand. Call it from TestMain so production Git helpers invoked anywhere in the package cannot observe host settings.

Types

This section is empty.

Jump to

Keyboard shortcuts

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