integration

package
v0.25.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 11, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTestDB

func NewTestDB(t *testing.T) *statedb.StateDB

NewTestDB creates an isolated SQLite database in a temp directory. Migrate is called automatically. The database is closed via t.Cleanup.

func WaitForCondition

func WaitForCondition(t TestingT, timeout, poll time.Duration, desc string, condition func() bool)

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

func WaitForPaneContent(t TestingT, inst *session.Instance, contains string, timeout time.Duration)

WaitForPaneContent polls the tmux pane output until it contains the expected string. Uses a 200ms poll interval. Handles nil tmux session gracefully (keeps polling).

func WaitForStatus

func WaitForStatus(t TestingT, inst *session.Instance, status session.Status, timeout time.Duration)

WaitForStatus polls until the instance reaches the expected status. Uses a 200ms poll interval.

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

type TestingT interface {
	Helper()
	Fatalf(format string, args ...any)
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL