Documentation
¶
Index ¶
- Variables
- func WithRepository(t *testing.T, name string, setup RepositorySetup, ...)
- type RepositorySetup
- type UserActions
- func (u *UserActions) CheckoutBranchInSourceRepo(branchName string)
- func (u *UserActions) CorruptWorktree(envID string)
- func (u *UserActions) CreateBranchInSourceRepo(branchName string)
- func (u *UserActions) CreateEnvironment(title, explanation string) *environment.Environment
- func (u *UserActions) FileDelete(envID, targetFile, explanation string)
- func (u *UserActions) FileRead(envID, targetFile string) string
- func (u *UserActions) FileReadExpectError(envID, targetFile string)
- func (u *UserActions) FileWrite(envID, targetFile, contents, explanation string)
- func (u *UserActions) GetEnvironment(envID string) *environment.Environment
- func (u *UserActions) GitCommand(args ...string) string
- func (u *UserActions) ReadWorktreeFile(envID, path string) string
- func (u *UserActions) RunCommand(envID, command, explanation string) string
- func (u *UserActions) UpdateEnvironment(envID, title, explanation string, config *environment.EnvironmentConfig)
- func (u *UserActions) WithDirectAccess(repoDir, configDir string) *UserActions
- func (u *UserActions) WorktreePath(envID string) string
- func (u *UserActions) WriteFileInSourceRepo(path, content, commitMessage string)
- func (u *UserActions) WriteSourceFile(path, content string)
Constants ¶
This section is empty.
Variables ¶
var ( SetupPythonRepo = func(t *testing.T, repoDir string) { writeFile(t, repoDir, "main.py", "def main():\n print('Hello World')\n\nif __name__ == '__main__':\n main()\n") writeFile(t, repoDir, "requirements.txt", "requests==2.31.0\nnumpy==1.24.0\n") writeFile(t, repoDir, ".gitignore", "__pycache__/\n*.pyc\n.env\nvenv/\n") gitCommit(t, repoDir, "Initial Python project") } SetupPythonRepoNoGitignore = func(t *testing.T, repoDir string) { writeFile(t, repoDir, "main.py", "def main():\n print('Hello World')\n\nif __name__ == '__main__':\n main()\n") writeFile(t, repoDir, "requirements.txt", "requests==2.31.0\nnumpy==1.24.0\n") gitCommit(t, repoDir, "Initial Python project") } SetupNodeRepo = func(t *testing.T, repoDir string) { packageJSON := `{ "name": "test-project", "version": "1.0.0", "main": "index.js", "scripts": { "start": "node index.js", "test": "jest" }, "dependencies": { "express": "^4.18.0" } }` writeFile(t, repoDir, "package.json", packageJSON) writeFile(t, repoDir, "index.js", "console.log('Hello from Node.js');\n") writeFile(t, repoDir, ".gitignore", "node_modules/\n.env\n") gitCommit(t, repoDir, "Initial Node project") } SetupEmptyRepo = func(t *testing.T, repoDir string) { writeFile(t, repoDir, "README.md", "# Test Project\n") gitCommit(t, repoDir, "Initial commit") } )
Common repository setups
Functions ¶
func WithRepository ¶
func WithRepository(t *testing.T, name string, setup RepositorySetup, fn func(t *testing.T, repo *repository.Repository, user *UserActions))
WithRepository runs a test function with an isolated repository and UserActions
Types ¶
type RepositorySetup ¶
RepositorySetup is a function that prepares a test repository
type UserActions ¶
type UserActions struct {
// contains filtered or unexported fields
}
UserActions provides test helpers that mirror MCP tool behavior exactly These represent what a user would experience when using the MCP tools
func NewUserActions ¶
func NewUserActions(t *testing.T, repo *repository.Repository, dag *dagger.Client) *UserActions
func (*UserActions) CheckoutBranchInSourceRepo ¶ added in v0.4.2
func (u *UserActions) CheckoutBranchInSourceRepo(branchName string)
CheckoutBranchInSourceRepo checks out an existing branch in the source repo
func (*UserActions) CorruptWorktree ¶
func (u *UserActions) CorruptWorktree(envID string)
CorruptWorktree simulates worktree corruption for recovery testing
func (*UserActions) CreateBranchInSourceRepo ¶ added in v0.4.2
func (u *UserActions) CreateBranchInSourceRepo(branchName string)
CreateBranchInSourceRepo creates and checks out a new branch in the source repo
func (*UserActions) CreateEnvironment ¶
func (u *UserActions) CreateEnvironment(title, explanation string) *environment.Environment
CreateEnvironment mirrors environment_create MCP tool behavior
func (*UserActions) FileDelete ¶
func (u *UserActions) FileDelete(envID, targetFile, explanation string)
FileDelete mirrors environment_file_delete MCP tool behavior
func (*UserActions) FileRead ¶
func (u *UserActions) FileRead(envID, targetFile string) string
FileRead mirrors environment_file_read MCP tool behavior (read-only, no update)
func (*UserActions) FileReadExpectError ¶
func (u *UserActions) FileReadExpectError(envID, targetFile string)
FileReadExpectError is for testing expected failures
func (*UserActions) FileWrite ¶
func (u *UserActions) FileWrite(envID, targetFile, contents, explanation string)
FileWrite mirrors environment_file_write MCP tool behavior
func (*UserActions) GetEnvironment ¶
func (u *UserActions) GetEnvironment(envID string) *environment.Environment
GetEnvironment retrieves an environment by ID - mirrors how MCP tools work Each MCP tool call starts fresh by getting the environment from the repository
func (*UserActions) GitCommand ¶
func (u *UserActions) GitCommand(args ...string) string
GitCommand runs a git command in the source repository
func (*UserActions) ReadWorktreeFile ¶
func (u *UserActions) ReadWorktreeFile(envID, path string) string
ReadWorktreeFile reads directly from an environment's worktree
func (*UserActions) RunCommand ¶
func (u *UserActions) RunCommand(envID, command, explanation string) string
RunCommand mirrors environment_run_cmd MCP tool behavior
func (*UserActions) UpdateEnvironment ¶
func (u *UserActions) UpdateEnvironment(envID, title, explanation string, config *environment.EnvironmentConfig)
UpdateEnvironment mirrors environment_update MCP tool behavior
func (*UserActions) WithDirectAccess ¶
func (u *UserActions) WithDirectAccess(repoDir, configDir string) *UserActions
WithDirectAccess adds direct filesystem access for edge case testing
func (*UserActions) WorktreePath ¶ added in v0.2.0
func (u *UserActions) WorktreePath(envID string) string
WorktreePath returns the worktree path for an environment, handling errors
func (*UserActions) WriteFileInSourceRepo ¶ added in v0.4.2
func (u *UserActions) WriteFileInSourceRepo(path, content, commitMessage string)
WriteFileInSourceRepo writes a file to the source repo and commits it
func (*UserActions) WriteSourceFile ¶
func (u *UserActions) WriteSourceFile(path, content string)
WriteSourceFile writes directly to the source repository