Documentation
¶
Index ¶
- func NewTestDB(t *testing.T) *statedb.StateDB
- func WaitForCondition(t TestingT, timeout, poll time.Duration, desc string, condition func() bool)
- func WaitForPaneContent(t TestingT, inst *session.Instance, contains string, timeout time.Duration)
- func WaitForStatus(t TestingT, inst *session.Instance, status session.Status, ...)
- type InstanceBuilder
- func (b *InstanceBuilder) Build() *statedb.InstanceRow
- func (b *InstanceBuilder) BuildSlice() []*statedb.InstanceRow
- func (b *InstanceBuilder) WithCommand(cmd string) *InstanceBuilder
- func (b *InstanceBuilder) WithGroup(path string) *InstanceBuilder
- func (b *InstanceBuilder) WithParent(id string) *InstanceBuilder
- func (b *InstanceBuilder) WithProject(path string) *InstanceBuilder
- func (b *InstanceBuilder) WithStatus(s string) *InstanceBuilder
- func (b *InstanceBuilder) WithTool(tool string) *InstanceBuilder
- type TestingT
- type TmuxHarness
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewTestDB ¶
NewTestDB creates an isolated SQLite database in a temp directory. Migrate is called automatically. The database is closed via t.Cleanup.
func WaitForCondition ¶
WaitForCondition polls condition at the given interval until it returns true or the timeout expires. On timeout, it calls t.Fatalf with a descriptive message including the timeout duration and description.
func WaitForPaneContent ¶
WaitForPaneContent polls the tmux pane output until it contains the expected string. Uses a 200ms poll interval. Handles nil tmux session gracefully (keeps polling).
Types ¶
type InstanceBuilder ¶
type InstanceBuilder struct {
// contains filtered or unexported fields
}
InstanceBuilder provides a fluent API for constructing statedb.InstanceRow values with sensible defaults for testing.
func NewInstanceBuilder ¶
func NewInstanceBuilder(id, title string) *InstanceBuilder
NewInstanceBuilder creates a builder with defaults: ProjectPath="/tmp/test", GroupPath="test-group", Tool="shell", Status="idle", CreatedAt=time.Now(), ToolData="{}".
func (*InstanceBuilder) Build ¶
func (b *InstanceBuilder) Build() *statedb.InstanceRow
Build returns the constructed InstanceRow.
func (*InstanceBuilder) BuildSlice ¶
func (b *InstanceBuilder) BuildSlice() []*statedb.InstanceRow
BuildSlice returns the constructed InstanceRow wrapped in a single-element slice. Convenience for db.SaveInstances().
func (*InstanceBuilder) WithCommand ¶
func (b *InstanceBuilder) WithCommand(cmd string) *InstanceBuilder
WithCommand sets the command field.
func (*InstanceBuilder) WithGroup ¶
func (b *InstanceBuilder) WithGroup(path string) *InstanceBuilder
WithGroup sets the group path.
func (*InstanceBuilder) WithParent ¶
func (b *InstanceBuilder) WithParent(id string) *InstanceBuilder
WithParent sets the parent session ID.
func (*InstanceBuilder) WithProject ¶
func (b *InstanceBuilder) WithProject(path string) *InstanceBuilder
WithProject sets the project path.
func (*InstanceBuilder) WithStatus ¶
func (b *InstanceBuilder) WithStatus(s string) *InstanceBuilder
WithStatus sets the status field.
func (*InstanceBuilder) WithTool ¶
func (b *InstanceBuilder) WithTool(tool string) *InstanceBuilder
WithTool sets the tool field.
type TestingT ¶
TestingT is the subset of *testing.T used by polling helpers. This allows testing the timeout path without killing the real test.
type TmuxHarness ¶
type TmuxHarness struct {
// contains filtered or unexported fields
}
TmuxHarness manages tmux sessions for integration tests with automatic cleanup. Sessions are created with a test-unique prefix and torn down via t.Cleanup.
func NewTmuxHarness ¶
func NewTmuxHarness(t *testing.T) *TmuxHarness
NewTmuxHarness creates a harness that auto-cleans tmux sessions when the test ends. Skips the test if no tmux server is available.
func (*TmuxHarness) CreateSession ¶
func (h *TmuxHarness) CreateSession(title, projectPath string) *session.Instance
CreateSession creates a session.Instance with the harness prefix prepended to the title. The session is tracked for automatic cleanup.
func (*TmuxHarness) CreateSessionWithTool ¶
func (h *TmuxHarness) CreateSessionWithTool(title, projectPath, tool string) *session.Instance
CreateSessionWithTool creates a session.Instance with a specific tool and the harness prefix.
func (*TmuxHarness) SessionCount ¶
func (h *TmuxHarness) SessionCount() int
SessionCount returns the number of sessions tracked by this harness.