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 ¶
- func BranchExists(t *testing.T, repoDir, branchName string) bool
- func CreateBranch(t *testing.T, dir string, name string)
- func GetHeadHash(t *testing.T, repoDir string) string
- func GitAdd(t *testing.T, repoDir string, paths ...string)
- func GitCheckoutNewBranch(t *testing.T, repoDir, branchName string)
- func GitCommit(t *testing.T, repoDir, message string)
- func GitIsolatedEnv() []string
- func GitReset(t *testing.T, dir string, ref string)
- func InitRepo(t *testing.T, repoDir string)
- func IsolateGitConfigEnv(t *testing.T)
- func WriteFile(t *testing.T, repoDir, path, content string)
- type RewindPoint
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BranchExists ¶
BranchExists checks if a branch exists in the repository.
func CreateBranch ¶ added in v0.5.6
CreateBranch creates a local branch at the current HEAD.
func GetHeadHash ¶
GetHeadHash returns the current HEAD commit hash.
func GitCheckoutNewBranch ¶
GitCheckoutNewBranch creates and checks out a new branch. Uses git CLI to work around go-git v5 bug with checkout deleting untracked 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 IsolateGitConfigEnv ¶ added in v0.7.0
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.
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.