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
- func AddRemote(t *testing.T, repoDir, name, url string)
- 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 GitAddForce(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 GitUpdateRef(t *testing.T, repoDir, ref, hash string)
- func InitRepo(t *testing.T, repoDir string)
- func IsolateGitConfigEnv(t *testing.T)
- func RunGit(t *testing.T, dir string, args ...string) string
- func SkipWithoutSymlinks(t *testing.T)
- func WriteCheckpointPushRemoteSetting(t *testing.T, repoDir, remoteName string)
- func WriteFile(t *testing.T, repoDir, path, content string)
- type PendingCheckpoint
Constants ¶
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
AddRemote adds a git remote named name pointing at url in repoDir.
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 GitAddForce ¶ added in v0.10.2
GitAddForce stages paths past .gitignore. GitAdd goes through go-git's worktree.Add, which has no force option.
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; 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 GitUpdateRef ¶ added in v0.10.0
GitUpdateRef points ref at hash in repoDir via git update-ref.
func IsolateGitConfigEnv ¶ added in v0.7.0
IsolateGitConfigEnv applies git config isolation to the current process; see gitenv.IsolateProcess.
func RunGit ¶ added in v0.10.2
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 ¶ added in v0.10.6
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
WriteCheckpointPushRemoteSetting writes .entire/settings.json configuring strategy_options.checkpoint_push_remote to remoteName (with enabled: true).
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.