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 FileExists(repoDir, path string) bool
- func GetCommitMessage(t *testing.T, repoDir, hash string) string
- func GetHeadHash(t *testing.T, repoDir string) string
- func GetLatestCheckpointIDFromHistory(t *testing.T, repoDir string) (string, error)
- 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 InitRepo(t *testing.T, repoDir string)
- func ReadFile(t *testing.T, repoDir, path string) string
- func SafeIDPrefix(id string) string
- func TryReadFile(t *testing.T, repoDir, path string) string
- 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 FileExists ¶
FileExists checks if a file exists in the repo directory.
func GetCommitMessage ¶
GetCommitMessage returns the commit message for the given commit hash.
func GetHeadHash ¶
GetHeadHash returns the current HEAD commit hash.
func GetLatestCheckpointIDFromHistory ¶
GetLatestCheckpointIDFromHistory walks backwards from HEAD and returns the checkpoint ID from the first commit with an Entire-Checkpoint trailer. Returns an error if no checkpoint trailer is found in any commit.
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
Existing GIT_CONFIG_GLOBAL/GIT_CONFIG_SYSTEM entries are filtered out before appending overrides to ensure they take effect regardless of parent env.
func SafeIDPrefix ¶
SafeIDPrefix returns first 12 chars of ID or the full ID if shorter. Use this when logging checkpoint IDs to avoid index out of bounds panic.
func TryReadFile ¶
TryReadFile reads a file from the repo directory, returning empty string if not found.
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.