Documentation
¶
Overview ¶
Package testutil provides testing utilities for the co orchestrator.
Index ¶
- type TestHarness
- func (h *TestHarness) AddBeadToWork(workID, beadID string)
- func (h *TestHarness) AddReviewIssues(parentID string, issues []beads.Bead)
- func (h *TestHarness) Cleanup()
- func (h *TestHarness) CompleteTask(taskID string)
- func (h *TestHarness) CountReviewIterations(workID string) int
- func (h *TestHarness) CreateBead(id, title string) *beads.Bead
- func (h *TestHarness) CreateEpicWithChildren(epicID string, childIDs ...string) *beads.Bead
- func (h *TestHarness) CreateReviewTask(taskID, workID string) *db.Task
- func (h *TestHarness) CreateTask(taskID, workID string, beadIDs []string) *db.Task
- func (h *TestHarness) CreateWork(workID, branch string) *db.Work
- func (h *TestHarness) CreateWorkWithRootIssue(workID, branch, rootIssueID string) *db.Work
- func (h *TestHarness) FailTask(taskID, errorMsg string)
- func (h *TestHarness) MockBranchExists(branchName string, local, remote bool)
- func (h *TestHarness) MockClaudeCompletesSuccessfully()
- func (h *TestHarness) MockClaudeFails(err error)
- func (h *TestHarness) MockGitPushFails(err error)
- func (h *TestHarness) MockGitPushSucceeds()
- func (h *TestHarness) MockWorktreeCreationFails(err error)
- func (h *TestHarness) SetBeadDependency(beadID, dependsOnID string)
- func (h *TestHarness) SimulateReviewCompletion(reviewTaskID, workID string, reviewIssues []beads.Bead) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TestHarness ¶
type TestHarness struct {
T *testing.T
DB *db.DB
Git *git.GitOperationsMock
Worktree *worktree.WorktreeOperationsMock
Beads *beads.BeadsCLIMock
BeadsReader *beads.BeadsReaderMock
OrchestratorManager *work.OrchestratorManagerMock
NameGenerator *names.GeneratorMock
TaskPlanner *task.PlannerMock
WorkService *work.WorkService
Config *project.Config
// contains filtered or unexported fields
}
TestHarness provides a complete test environment with pre-wired mocks for integration testing work flows without external dependencies.
func NewTestHarness ¶
func NewTestHarness(t *testing.T) *TestHarness
NewTestHarness creates a new TestHarness with an in-memory database and all mocks pre-configured with sensible defaults.
func (*TestHarness) AddBeadToWork ¶
func (h *TestHarness) AddBeadToWork(workID, beadID string)
AddBeadToWork associates a bead with a work in the database.
func (*TestHarness) AddReviewIssues ¶
func (h *TestHarness) AddReviewIssues(parentID string, issues []beads.Bead)
AddReviewIssues adds beads that simulate issues created by a review task. These beads are added as children of the specified parent bead.
func (*TestHarness) Cleanup ¶
func (h *TestHarness) Cleanup()
Cleanup releases resources used by the harness. Should be called with defer after NewTestHarness.
func (*TestHarness) CompleteTask ¶
func (h *TestHarness) CompleteTask(taskID string)
CompleteTask marks a task as completed in the database.
func (*TestHarness) CountReviewIterations ¶
func (h *TestHarness) CountReviewIterations(workID string) int
CountReviewIterations counts the number of completed review tasks for a work.
func (*TestHarness) CreateBead ¶
func (h *TestHarness) CreateBead(id, title string) *beads.Bead
CreateBead creates a test bead and stores it in the harness. The bead is created with status "open" and type "task" by default.
func (*TestHarness) CreateEpicWithChildren ¶
func (h *TestHarness) CreateEpicWithChildren(epicID string, childIDs ...string) *beads.Bead
CreateEpicWithChildren creates an epic bead with child beads. The epic is created with the given ID, and children are created with the parent-child dependency relationship.
func (*TestHarness) CreateReviewTask ¶
func (h *TestHarness) CreateReviewTask(taskID, workID string) *db.Task
CreateReviewTask creates a review task in the database using GetNextTaskNumber. Review tasks have no beads associated with them directly. If taskID is empty, generates a new task ID using the atomic counter. Returns the created task with its actual ID.
func (*TestHarness) CreateTask ¶
func (h *TestHarness) CreateTask(taskID, workID string, beadIDs []string) *db.Task
CreateTask creates a task in the database with the given beads. Returns the created task.
func (*TestHarness) CreateWork ¶
func (h *TestHarness) CreateWork(workID, branch string) *db.Work
CreateWork creates a work record in the database with the given ID and branch. Returns the created work.
func (*TestHarness) CreateWorkWithRootIssue ¶
func (h *TestHarness) CreateWorkWithRootIssue(workID, branch, rootIssueID string) *db.Work
CreateWorkWithRootIssue creates a work record with an optional root issue ID. Returns the created work.
func (*TestHarness) FailTask ¶
func (h *TestHarness) FailTask(taskID, errorMsg string)
FailTask marks a task as failed with an error message in the database.
func (*TestHarness) MockBranchExists ¶
func (h *TestHarness) MockBranchExists(branchName string, local, remote bool)
MockBranchExists configures the Git mock to indicate a branch exists.
func (*TestHarness) MockClaudeCompletesSuccessfully ¶
func (h *TestHarness) MockClaudeCompletesSuccessfully()
MockClaudeCompletesSuccessfully configures the orchestrator mock to indicate successful completion.
func (*TestHarness) MockClaudeFails ¶
func (h *TestHarness) MockClaudeFails(err error)
MockClaudeFails configures the orchestrator mock to return an error.
func (*TestHarness) MockGitPushFails ¶
func (h *TestHarness) MockGitPushFails(err error)
MockGitPushFails configures the Git mock to return an error on push.
func (*TestHarness) MockGitPushSucceeds ¶
func (h *TestHarness) MockGitPushSucceeds()
MockGitPushSucceeds configures the Git mock to succeed on push.
func (*TestHarness) MockWorktreeCreationFails ¶
func (h *TestHarness) MockWorktreeCreationFails(err error)
MockWorktreeCreationFails configures the worktree mock to return an error on creation.
func (*TestHarness) SetBeadDependency ¶
func (h *TestHarness) SetBeadDependency(beadID, dependsOnID string)
SetBeadDependency creates a blocking dependency between two beads. The bead identified by beadID will be blocked by dependsOnID.
func (*TestHarness) SimulateReviewCompletion ¶
func (h *TestHarness) SimulateReviewCompletion(reviewTaskID, workID string, reviewIssues []beads.Bead) bool
SimulateReviewCompletion simulates completing a review task and checking for issues. Returns true if there are beads to fix (issues created by the review).