Documentation
¶
Overview ¶
Package testutil supplies deterministic fixtures for Taskronin tests. Production packages must not import it.
Index ¶
- Constants
- Variables
- func AI() domain.Actor
- func After(id domain.TaskID) func(*service.AddTaskIn)
- func Before(id domain.TaskID) func(*service.AddTaskIn)
- func BlockAt(span string) func(*service.AddTaskIn)
- func Bottom() func(*service.AddTaskIn)
- func Clock(t testing.TB, local string) *clock.Fake
- func D(s string) civil.Date
- func DeferTo(m string) func(*service.AddTaskIn)
- func Due(m string) func(*service.AddTaskIn)
- func Golden(t testing.TB, name string, got []byte)
- func Local(t testing.TB, s string) time.Time
- func Meta(a domain.Actor, gen domain.Generation) service.Meta
- func Moment(s string) domain.Moment
- func Now() func(*service.AddTaskIn)
- func Owner() domain.Actor
- func RequireCode(t testing.TB, err error, want domain.Code)
- func Service(t testing.TB, opts ...SvcOpt) (*service.Service, *clock.Fake)
- func Store(t testing.TB) *store.Store
- func StoreNoCheck(t testing.TB) *store.Store
- func TokenActor(name string, sc domain.Scopes) domain.Actor
- func Top() func(*service.AddTaskIn)
- type Scenario
- func (s *Scenario) Add(title string, mods ...func(*service.AddTaskIn)) domain.TaskID
- func (s *Scenario) As(a domain.Actor) *Scenario
- func (s *Scenario) At(when string) *Scenario
- func (s *Scenario) Backlog() []domain.TaskID
- func (s *Scenario) Block(task domain.TaskID, span string) domain.BlockID
- func (s *Scenario) BlockExpect(id domain.BlockID) domain.Expect
- func (s *Scenario) BlockState(id domain.BlockID) string
- func (s *Scenario) BlockView(id domain.BlockID) domain.BlockView
- func (s *Scenario) Ctx() context.Context
- func (s *Scenario) Defer(id domain.TaskID, moment string)
- func (s *Scenario) Delete(id domain.TaskID)
- func (s *Scenario) DeleteEntry(id domain.EntryID)
- func (s *Scenario) Done(id domain.TaskID, mods ...func(*service.CompleteIn))
- func (s *Scenario) Drop(id domain.TaskID)
- func (s *Scenario) EditEntry(id domain.EntryID, mods ...func(*service.UpdateEntryIn))
- func (s *Scenario) EntryExpect(id domain.EntryID) domain.Expect
- func (s *Scenario) EventKeys(op domain.OpID) []string
- func (s *Scenario) Events(op domain.OpID) []domain.Event
- func (s *Scenario) Exec(query string, args ...any)
- func (s *Scenario) Expect(id domain.TaskID) domain.Expect
- func (s *Scenario) Focus() domain.Focus
- func (s *Scenario) Interruptions(date string) []domain.Interruption
- func (s *Scenario) Log(task domain.TaskID, text, date string) domain.EntryID
- func (s *Scenario) LogAt(task domain.TaskID, text, date, at string) domain.EntryID
- func (s *Scenario) MarkManual(id domain.TaskID)
- func (s *Scenario) Meta() service.Meta
- func (s *Scenario) MetaWith(key, body string) service.Meta
- func (s *Scenario) Must(r *service.OpResult, err error) *service.OpResult
- func (s *Scenario) Op(id domain.OpID) domain.OpRecord
- func (s *Scenario) OpCount() int
- func (s *Scenario) Outcome(b domain.BlockID, o domain.UserOutcome)
- func (s *Scenario) Place(id domain.TaskID, how domain.PlaceHow, ref ...domain.TaskID)
- func (s *Scenario) Reasons(id domain.TaskID) []domain.TriageReason
- func (s *Scenario) Reblock(b domain.BlockID, span string) domain.BlockID
- func (s *Scenario) Reconcile()
- func (s *Scenario) Redo() *service.OpResult
- func (s *Scenario) Relink(id domain.EntryID, task domain.TaskID)
- func (s *Scenario) Reopen(id domain.TaskID, removeEntry bool)
- func (s *Scenario) Revert(op domain.OpID) *service.OpResult
- func (s *Scenario) SeqFloor(table string, next int64)
- func (s *Scenario) SetDue(id domain.TaskID, moment string)
- func (s *Scenario) SetFocus(task domain.TaskID, interrupt bool)
- func (s *Scenario) Slips(id domain.TaskID) (lifetime, sinceTriage int)
- func (s *Scenario) Stack(actor string, which store.Stack) []domain.OpID
- func (s *Scenario) StateDigest() string
- func (s *Scenario) Task(id domain.TaskID) domain.TaskView
- func (s *Scenario) Unblock(b domain.BlockID)
- func (s *Scenario) Undelete(id domain.TaskID)
- func (s *Scenario) UndeleteEntry(id domain.EntryID)
- func (s *Scenario) Undo() *service.OpResult
- func (s *Scenario) Update(id domain.TaskID, mods ...func(*service.UpdateTaskIn))
- type Server
- type ServerOpt
- type SvcOpt
- type SyncBuffer
Constants ¶
const DefaultNow = "2026-10-28 10:00"
DefaultNow is the catalog's default local instant.
const Password = "correct horse battery"
Password is the one fixed test password permitted by A§13.1.
Variables ¶
var Zone = mustZone()
Zone is the catalog's America/Denver civil time zone.
Functions ¶
func BlockAt ¶
BlockAt places a new task in a catalog span; an omitted date means the scenario's today.
func Golden ¶
Golden compares got with testdata/golden/<name>.golden, relative to the calling package's working directory. Pass -update to rewrite the fixture.
func RequireCode ¶
RequireCode fails unless err is a domain error with the expected code.
func Store ¶
Store creates a migrated, bootstrapped database and checks FTS and structural invariants during cleanup.
func StoreNoCheck ¶
StoreNoCheck creates a store without cleanup checks for deliberate corruption tests.
func TokenActor ¶
TokenActor returns an API actor with the supplied token name and scopes.
Types ¶
type Scenario ¶
type Scenario struct {
T testing.TB
Svc *service.Service
Clock *clock.Fake
Store *store.Store
Actor domain.Actor
Last *service.OpResult
}
Scenario holds a service fixture and the actor for fluent catalog operations.
func NewScenario ¶
NewScenario constructs an isolated fixture acting as the owner.
func (*Scenario) Backlog ¶
Backlog independently queries open, undeleted, undeferred tasks without reasons.
func (*Scenario) Block ¶
Block schedules a task using its current precondition; an omitted date means today.
func (*Scenario) BlockExpect ¶
BlockExpect returns the block's current version in the live database generation.
func (*Scenario) BlockState ¶
BlockState returns the catalog tuple {status, source, slipped, cancel}.
func (*Scenario) Defer ¶
Defer places a task at a defer moment, or clears its defer when moment is empty.
func (*Scenario) DeleteEntry ¶
DeleteEntry tombstones an entry using its current precondition.
func (*Scenario) Done ¶
func (s *Scenario) Done(id domain.TaskID, mods ...func(*service.CompleteIn))
Done completes a task using its current precondition and input modifiers.
func (*Scenario) EditEntry ¶
func (s *Scenario) EditEntry(id domain.EntryID, mods ...func(*service.UpdateEntryIn))
EditEntry edits an entry using its current precondition and input modifiers.
func (*Scenario) EntryExpect ¶
EntryExpect returns the entry's current version in the live database generation.
func (*Scenario) EventKeys ¶
EventKeys returns compact entity/action labels with IDs, triage reasons and derivation.
func (*Scenario) Expect ¶
Expect returns the task's current version in the live database generation.
func (*Scenario) Interruptions ¶
func (s *Scenario) Interruptions(date string) []domain.Interruption
Interruptions returns live interruptions on a catalog date.
func (*Scenario) LogAt ¶
LogAt records work with an optional HH:MM time; task 0 is standalone, date "" is today.
func (*Scenario) MarkManual ¶
MarkManual requests manual triage using the task's current precondition.
func (*Scenario) MetaWith ¶
MetaWith returns a request with an explicit idempotency key and canonical body.
func (*Scenario) Outcome ¶
func (s *Scenario) Outcome(b domain.BlockID, o domain.UserOutcome)
Outcome sets a block's outcome policy using its current precondition.
func (*Scenario) Place ¶
Place acknowledges triage and positions a task using its current precondition.
func (*Scenario) Reasons ¶
func (s *Scenario) Reasons(id domain.TaskID) []domain.TriageReason
Reasons returns a task's triage reasons in descending priority order.
func (*Scenario) Reblock ¶
Reblock reschedules a block and returns the resulting planned block's ID.
func (*Scenario) Reconcile ¶
func (s *Scenario) Reconcile()
Reconcile applies pending time-dependent transitions at the current fake instant.
func (*Scenario) Redo ¶
Redo reapplies the current actor's newest redo entry with a fresh request key.
func (*Scenario) Relink ¶
Relink changes an entry's task using its current precondition; task 0 is standalone.
func (*Scenario) Revert ¶
Revert reverses an operation using the current actor and a fresh request key.
func (*Scenario) StateDigest ¶
StateDigest returns deterministic live user state, excluding bookkeeping clocks, versions and sequences. Task order is represented by IDs rather than rank values.
func (*Scenario) UndeleteEntry ¶
UndeleteEntry restores an entry using its current precondition.
type Server ¶
type Server struct {
Client *client.Client
Clock *clock.Fake
Svc *service.Service
DataDir, Socket string
Paths config.Paths
WebURL string
Log *SyncBuffer
// contains filtered or unexported fields
}
Server is a real, restartable socket server with isolated data and fake time.
func StartServer ¶
StartServer initializes real data and starts Run, waiting for its health endpoint. It changes environment variables and must not be used by parallel tests.
type ServerOpt ¶
type ServerOpt func(*serverOpts)
ServerOpt configures a StartServer fixture.
func WithConfig ¶
WithConfig changes effective server configuration before initialization.
func WithMCPToken ¶
func WithMCPToken() ServerOpt
WithMCPToken initializes the default MCP token as well as the owner token.
type SyncBuffer ¶
type SyncBuffer struct {
// contains filtered or unexported fields
}
SyncBuffer is a goroutine-safe log sink.
func (*SyncBuffer) String ¶
func (b *SyncBuffer) String() string