Documentation
¶
Overview ¶
Package hosttest is an in-memory host broker for the Slack plugin's tests: it records what the plugin reports, proposes and writes, applies item ops with the host ledger's rules, and answers asks from a script.
Index ¶
- type Host
- func (h *Host) Apply(prov items.Provenance, ops ...items.Op) error
- func (h *Host) ApplyItems(_ context.Context, ops []src.ItemOp) ([]src.ItemResult, error)
- func (h *Host) Ask(ctx context.Context, req src.AskRequest) (src.AskResult, error)
- func (h *Host) Asks() []src.AskRequest
- func (h *Host) Books(context.Context, []plugin.Unit) ([]src.Book, error)
- func (h *Host) Briefs() []src.Brief
- func (h *Host) Broker() host.Broker
- func (h *Host) Changed(_ context.Context, units []plugin.Unit, _ []plugin.Topic) error
- func (h *Host) Config(context.Context) (src.Config, error)
- func (h *Host) Drafts(u unit.Unit) int
- func (h *Host) Events(_ context.Context, q src.EventQuery) ([]src.Event, error)
- func (h *Host) Gates() []src.GateRequest
- func (*Host) Holds(context.Context, string, [][]src.Fact) ([]src.Holding, error)
- func (h *Host) Items(u unit.Unit) []items.Item
- func (h *Host) Links() []link.Link
- func (h *Host) Meter(_ context.Context, s src.Sample) error
- func (h *Host) Moves() []src.UnitMove
- func (h *Host) OpenGate(_ context.Context, req src.GateRequest) (src.GateRef, error)
- func (h *Host) Ops() [][]src.ItemOp
- func (h *Host) Profile(_ context.Context, path string) ([]byte, error)
- func (h *Host) Proposals() []items.Op
- func (h *Host) Put(its ...items.Item)
- func (h *Host) PutBrief(_ context.Context, b src.Brief) error
- func (h *Host) QueryItems(_ context.Context, q src.ItemQuery) ([]src.Item, error)
- func (h *Host) RecordEvents(_ context.Context, events []src.Event) error
- func (h *Host) RefuseWakes(err error)
- func (h *Host) RehomeDrafts(_ context.Context, moves []src.UnitMove) (int, error)
- func (h *Host) Report(_ context.Context, snaps []src.Snapshot) error
- func (h *Host) Reports() [][]src.Snapshot
- func (h *Host) RoundState(context.Context, plugin.Unit) (src.RoundState, error)
- func (h *Host) Samples() []src.Sample
- func (h *Host) Session(_ context.Context, handle string) (src.Session, error)
- func (h *Host) SetDrafts(u unit.Unit, n int)
- func (h *Host) SetMarks(_ context.Context, u plugin.Unit, marks map[string]string) error
- func (h *Host) SetOverride(context.Context, plugin.Unit, map[string]string, map[string]string) (bool, error)
- func (h *Host) SetSession(handle string, s src.Session)
- func (h *Host) SetTasks(ts ...src.Task)
- func (h *Host) Snapshot(u unit.Unit) (src.Snapshot, bool)
- func (h *Host) Snapshots() []src.Snapshot
- func (h *Host) Src() src.Host
- func (h *Host) Tasks(_ context.Context, units []plugin.Unit) ([]src.Task, error)
- func (h *Host) WakeJob(_ context.Context, job string, at time.Time) error
- func (h *Host) Wakes() []JobWake
- func (h *Host) Workspaces(context.Context, string) (src.Listing, error)
- type JobWake
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Host ¶
type Host struct {
// GateState is the state OpenGate answers a draft's gate left it in; "" answers none.
GateState string
// Now is the ledger's clock; nil is a fixed instant.
Now func() time.Time
// AskFunc answers Services.Ask; nil answers ErrUnsupported.
AskFunc func(ctx context.Context, req src.AskRequest) (src.AskResult, error)
// ProfileDirs are read in order by Services.Profile; the first that
// holds a path answers it.
ProfileDirs []string
// ProfileFiles answer Services.Profile before ProfileDirs.
ProfileFiles map[string][]byte
// Resolve is the unit a link op's address lands in; nil keeps the
// address as a unit with no provider.
Resolve func(address string) (unit.Unit, bool)
// Configured is what Services.Config answers.
Configured src.Config
// WakeErr is what WakeJob answers; nil records the wake.
WakeErr error
// Disabled says a provider is disabled: an ApplyItems with an op on one
// of its units fails whole, as the host's ledger does.
Disabled func(p unit.ProviderID) bool
// contains filtered or unexported fields
}
Host is a fake host. Its zero value is ready; set the fields that script it before the plugin calls it.
func (*Host) Apply ¶
Apply applies ops as prov, as another writer of the ledger would (the user, a turn); it returns the refusals.
func (*Host) ApplyItems ¶
ApplyItems applies the plugin's ops as extracted, as the host does.
func (*Host) Proposals ¶
Proposals are the ops the ledger held for the user because they would change an item the user confirmed.
func (*Host) QueryItems ¶
func (*Host) RecordEvents ¶
func (*Host) RefuseWakes ¶ added in v0.4.0
RefuseWakes makes WakeJob answer err; nil records wakes again.
func (*Host) RehomeDrafts ¶
func (*Host) RoundState ¶
func (*Host) SetOverride ¶
func (*Host) SetSession ¶
SetSession sets the session Reader.Session answers for handle.