hosttest

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: Apache-2.0 Imports: 18 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Host

type Host struct {
	// 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

func (h *Host) Apply(prov items.Provenance, ops ...items.Op) error

Apply applies ops as prov, as another writer of the ledger would (the user, a turn); it returns the refusals.

func (*Host) ApplyItems

func (h *Host) ApplyItems(_ context.Context, ops []src.ItemOp) ([]src.ItemResult, error)

ApplyItems applies the plugin's ops as extracted, as the host does.

func (*Host) Ask

func (h *Host) Ask(ctx context.Context, req src.AskRequest) (src.AskResult, error)

func (*Host) Asks

func (h *Host) Asks() []src.AskRequest

Asks are the Ask calls.

func (*Host) Books

func (h *Host) Books(context.Context, []plugin.Unit) ([]src.Book, error)

func (*Host) Briefs

func (h *Host) Briefs() []src.Brief

Briefs are the PutBrief calls.

func (*Host) Broker

func (h *Host) Broker() host.Broker

Broker is the fake as the plugin's broker.

func (*Host) Changed

func (h *Host) Changed(_ context.Context, units []plugin.Unit, _ []plugin.Topic) error

func (*Host) Config

func (h *Host) Config(context.Context) (src.Config, error)

func (*Host) Drafts

func (h *Host) Drafts(u unit.Unit) int

Drafts are how many drafts u has.

func (*Host) Events

func (h *Host) Events(_ context.Context, q src.EventQuery) ([]src.Event, error)

Events are the recorded events.

func (*Host) Gates

func (h *Host) Gates() []src.GateRequest

Gates are the OpenGate calls.

func (*Host) Holds added in v0.4.0

func (*Host) Holds(context.Context, string, [][]src.Fact) ([]src.Holding, error)

func (*Host) Items

func (h *Host) Items(u unit.Unit) []items.Item

Items are u's items, oldest first.

func (h *Host) Links() []link.Link

Links are the links the ledger keeps.

func (*Host) Meter

func (h *Host) Meter(_ context.Context, s src.Sample) error

func (*Host) Moves

func (h *Host) Moves() []src.UnitMove

Moves are the RehomeDrafts moves.

func (*Host) OpenGate

func (h *Host) OpenGate(_ context.Context, req src.GateRequest) (src.GateRef, error)

func (*Host) Ops

func (h *Host) Ops() [][]src.ItemOp

Ops are every ApplyItems call's ops, in order.

func (*Host) Profile

func (h *Host) Profile(_ context.Context, path string) ([]byte, error)

func (*Host) Proposals

func (h *Host) Proposals() []items.Op

Proposals are the ops the ledger held for the user because they would change an item the user confirmed.

func (*Host) Put

func (h *Host) Put(its ...items.Item)

Put stores it as is, as an item already in the ledger.

func (*Host) PutBrief

func (h *Host) PutBrief(_ context.Context, b src.Brief) error

func (*Host) QueryItems

func (h *Host) QueryItems(_ context.Context, q src.ItemQuery) ([]src.Item, error)

func (*Host) RecordEvents

func (h *Host) RecordEvents(_ context.Context, events []src.Event) error

func (*Host) RecordSent

func (h *Host) RecordSent(_ context.Context, d src.Draft, session, tool string) (src.GateRef, error)

func (*Host) RefuseWakes added in v0.4.0

func (h *Host) RefuseWakes(err error)

RefuseWakes makes WakeJob answer err; nil records wakes again.

func (*Host) RehomeDrafts

func (h *Host) RehomeDrafts(_ context.Context, moves []src.UnitMove) (int, error)

func (*Host) Report

func (h *Host) Report(_ context.Context, snaps []src.Snapshot) error

Report keeps each unit's latest snapshot.

func (*Host) Reports

func (h *Host) Reports() [][]src.Snapshot

Reports are every Report call's snapshots, in order.

func (*Host) RoundState

func (h *Host) RoundState(context.Context, plugin.Unit) (src.RoundState, error)

func (*Host) Samples

func (h *Host) Samples() []src.Sample

Samples are the metered samples.

func (*Host) SentDrafts

func (h *Host) SentDrafts() []Sent

SentDrafts are the RecordSent calls.

func (*Host) Session

func (h *Host) Session(_ context.Context, handle string) (src.Session, error)

Session answers a session SetSession set, else one with no unit.

func (*Host) SetDrafts

func (h *Host) SetDrafts(u unit.Unit, n int)

SetDrafts says u has n drafts, which RehomeDrafts moves and counts.

func (*Host) SetMarks

func (h *Host) SetMarks(_ context.Context, u plugin.Unit, marks map[string]string) error

func (*Host) SetOverride

func (h *Host) SetOverride(context.Context, plugin.Unit, map[string]string, map[string]string) (bool, error)

func (*Host) SetSession

func (h *Host) SetSession(handle string, s src.Session)

SetSession sets the session Reader.Session answers for handle.

func (*Host) SetTasks

func (h *Host) SetTasks(ts ...src.Task)

SetTasks sets the tasks Reader.Tasks answers from.

func (*Host) Snapshot

func (h *Host) Snapshot(u unit.Unit) (src.Snapshot, bool)

Snapshot is u's latest reported snapshot.

func (*Host) Snapshots

func (h *Host) Snapshots() []src.Snapshot

Snapshots are the latest snapshot of every unit reported and not gone.

func (*Host) Src

func (h *Host) Src() src.Host

Src is the fake as the SDK's Host.

func (*Host) Tasks

func (h *Host) Tasks(_ context.Context, units []plugin.Unit) ([]src.Task, error)

func (*Host) WakeJob added in v0.4.0

func (h *Host) WakeJob(_ context.Context, job string, at time.Time) error

WakeJob records the wake, unless WakeErr refuses it.

func (*Host) Wakes added in v0.4.0

func (h *Host) Wakes() []JobWake

Wakes are the WakeJob calls, in order.

func (*Host) Workspaces

func (h *Host) Workspaces(context.Context, string) (src.Listing, error)

type JobWake added in v0.4.0

type JobWake struct {
	Job string
	At  time.Time
}

JobWake is a WakeJob call.

type Sent

type Sent struct {
	Draft   src.Draft
	Session string
	Tool    string
}

Sent is a RecordSent call.

Jump to

Keyboard shortcuts

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