testutil

package
v0.10.6 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2026 License: MIT Imports: 11 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

View Source
const EnvGitHermetic = gitenv.EnvHermetic

EnvGitHermetic opts a test process into gitenv's hermetic transport config; see gitenv.EnvHermetic.

Variables

This section is empty.

Functions

func AddRemote added in v0.10.0

func AddRemote(t *testing.T, repoDir, name, url string)

AddRemote adds a git remote named name pointing at url in repoDir.

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 GitAddForce added in v0.10.2

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

GitAddForce stages paths past .gitignore. GitAdd goes through go-git's worktree.Add, which has no force option.

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; see gitenv.Isolated. The implementation lives in the dependency-free gitenv subpackage so internal tests of packages testutil imports (e.g. gitrepo) can use it without an import cycle; everything else keeps this spelling.

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 GitUpdateRef added in v0.10.0

func GitUpdateRef(t *testing.T, repoDir, ref, hash string)

GitUpdateRef points ref at hash in repoDir via git update-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 git config isolation to the current process; see gitenv.IsolateProcess.

func RunGit added in v0.10.2

func RunGit(t *testing.T, dir string, args ...string) string

RunGit runs one git command in dir with an isolated git config, failing the test on error and returning combined output. Use it for operations go-git cannot express (force-add past .gitignore, rm --cached, worktree add) or where shelling out is simply clearer. See gitenv.Run.

func SkipWithoutSymlinks(t *testing.T)

SkipWithoutSymlinks skips a test that needs to create a symlink. On Windows that takes elevation or developer mode, neither of which CI has.

Here rather than per-package because six copies in three different wordings had accumulated across cli, agent, worktreedir and vercelconfig tests, so there was nowhere to make the change when a runner does gain the privilege.

func WriteCheckpointPushRemoteSetting added in v0.10.0

func WriteCheckpointPushRemoteSetting(t *testing.T, repoDir, remoteName string)

WriteCheckpointPushRemoteSetting writes .entire/settings.json configuring strategy_options.checkpoint_push_remote to remoteName (with enabled: true).

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 PendingCheckpoint added in v0.10.4

type PendingCheckpoint 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"`
}

PendingCheckpoint mirrors the `checkpoint list --pending --json` JSON output.

Directories

Path Synopsis
Package gitenv isolates test git invocations from the host's git config.
Package gitenv isolates test git invocations from the host's git config.

Jump to

Keyboard shortcuts

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