testutil

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package testutil provides shared test utilities for both integration and e2e tests. This package has no build tags, making it usable by all test packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BranchExists

func BranchExists(t *testing.T, repoDir, branchName string) bool

BranchExists checks if a branch exists in the repository.

func CreateBranch added in v0.5.6

func CreateBranch(t *testing.T, dir string, name string)

CreateBranch creates a local branch at the current HEAD.

func GetHeadHash

func GetHeadHash(t *testing.T, repoDir string) string

GetHeadHash returns the current HEAD commit hash.

func GitAdd

func GitAdd(t *testing.T, repoDir string, paths ...string)

GitAdd stages files for commit.

func GitCheckoutNewBranch

func GitCheckoutNewBranch(t *testing.T, repoDir, branchName string)

GitCheckoutNewBranch creates and checks out a new branch. Uses git CLI to work around go-git v5 bug with checkout deleting untracked files.

func GitCommit

func GitCommit(t *testing.T, repoDir, message string)

GitCommit creates a commit with all staged files.

func GitIsolatedEnv added in v0.5.0

func GitIsolatedEnv() []string

GitIsolatedEnv returns os.Environ() with git isolation variables set. This prevents user/system git config (global gitignore, aliases, etc.) from affecting test behavior. Use this for any exec.Command that runs git or the CLI binary in integration tests.

See https://git-scm.com/docs/git#Documentation/git.txt-GITCONFIGGLOBAL

Every inherited GIT_CONFIG_* entry is filtered out — including GIT_CONFIG_PARAMETERS and the indexed KEY_/VALUE_ pairs that can inject `git -c` overrides — so our explicit isolation overrides take effect regardless of parent env.

func GitReset added in v0.5.6

func GitReset(t *testing.T, dir string, ref string)

GitReset runs git reset --hard to the given ref.

func InitRepo

func InitRepo(t *testing.T, repoDir string)

InitRepo initializes a git repository in the given directory with test user config.

func IsolateGitConfigEnv added in v0.7.0

func IsolateGitConfigEnv(t *testing.T)

IsolateGitConfigEnv applies the same git config isolation to the current process. Use this in tests that exercise production code paths which invoke git with os.Environ(). All inherited GIT_CONFIG_* variables are cleared before the isolation overrides are set, so values such as GIT_CONFIG_PARAMETERS or indexed KEY_/VALUE_ overrides cannot leak into child git invocations.

func WriteFile

func WriteFile(t *testing.T, repoDir, path, content string)

WriteFile creates a file with the given content in the repo directory. It creates parent directories as needed.

Types

type RewindPoint

type RewindPoint struct {
	ID               string    `json:"id"`
	Message          string    `json:"message"`
	MetadataDir      string    `json:"metadata_dir"`
	Date             time.Time `json:"date"`
	IsTaskCheckpoint bool      `json:"is_task_checkpoint"`
	ToolUseID        string    `json:"tool_use_id"`
	IsLogsOnly       bool      `json:"is_logs_only"`
	CondensationID   string    `json:"condensation_id"`
}

RewindPoint mirrors the rewind --list JSON output.

Jump to

Keyboard shortcuts

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