Documentation
¶
Index ¶
- type Harness
- func (h *Harness) AssertConverged(projectID string)
- func (h *Harness) CountEntities(clientID, entityType string) int
- func (h *Harness) Diff(clientA, clientB string) string
- func (h *Harness) Mutate(clientID, actionType, entityType, entityID string, data map[string]any) error
- func (h *Harness) Pull(clientID, projectID string) (tdsync.PullResult, error)
- func (h *Harness) PullAll(clientID, projectID string) (tdsync.PullResult, error)
- func (h *Harness) Push(clientID, projectID string) (tdsync.PushResult, error)
- func (h *Harness) PushWithoutMark(clientID, projectID string) (tdsync.PushResult, error)
- func (h *Harness) QueryEntity(clientID, entityType, entityID string) map[string]any
- func (h *Harness) QueryEntityRaw(clientID, entityType, entityID string) map[string]any
- func (h *Harness) Sync(clientID, projectID string) error
- func (h *Harness) UndoLastAction(clientID string) error
- type SimulatedClient
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Harness ¶
type Harness struct {
ProjectDBs map[string]*sql.DB
Clients map[string]*SimulatedClient
Validator tdsync.EntityValidator
// contains filtered or unexported fields
}
Harness orchestrates multi-client sync testing.
func NewHarness ¶
NewHarness creates a test harness with numClients and one server DB for projectID.
func (*Harness) AssertConverged ¶
AssertConverged verifies all clients have identical entity data.
func (*Harness) CountEntities ¶
CountEntities returns the number of rows in an entity table for a client.
func (*Harness) Mutate ¶
func (h *Harness) Mutate(clientID, actionType, entityType, entityID string, data map[string]any) error
Mutate performs a local mutation on a client's database and records it in action_log. For "delete" action: uses soft-delete on tables with deleted_at column (issues, board_issue_positions), hard delete on tables without it (issue_dependencies, issue_files, work_session_issues).
func (*Harness) Pull ¶
func (h *Harness) Pull(clientID, projectID string) (tdsync.PullResult, error)
Pull fetches new events from the server and applies them to the client.
func (*Harness) PullAll ¶
func (h *Harness) PullAll(clientID, projectID string) (tdsync.PullResult, error)
PullAll fetches all new events from the server (including own device) and applies them. This ensures convergence by replaying events in server-seq order regardless of origin.
func (*Harness) Push ¶
func (h *Harness) Push(clientID, projectID string) (tdsync.PushResult, error)
Push sends pending events from a client to the server.
func (*Harness) PushWithoutMark ¶
func (h *Harness) PushWithoutMark(clientID, projectID string) (tdsync.PushResult, error)
PushWithoutMark sends pending events to the server but skips MarkEventsSynced. This simulates a crash after the server accepts events but before the client records the acks.
func (*Harness) QueryEntity ¶
QueryEntity reads a single entity from a client's DB, returning nil if not found. For soft-delete tables (issues, board_issue_positions), filters out rows where deleted_at is set.
func (*Harness) QueryEntityRaw ¶
QueryEntityRaw reads a single entity from a client's DB without soft-delete filtering. Use this when you need to verify soft-deleted rows exist (e.g., checking deleted_at is set).
func (*Harness) UndoLastAction ¶
UndoLastAction simulates `td undo` for the last non-undone action on a client. It marks the action as undone=1 and inserts a compensating event:
- "create" action → soft_delete event
- "soft_delete" action → restore event (clears deleted_at)
- "update" action → update event with previous_data fields
This mirrors the behavior of cmd/undo.go.