Documentation
¶
Overview ¶
Package agenttest is the conformance kit for agent modules: an in-memory Host and a suite every module must pass.
Index ¶
- Constants
- func Run(t *testing.T, m agent.Module, newHost func(t *testing.T) *FakeHost)
- type FakeHost
- func (h *FakeHost) AddBinary(name, versionLine string)
- func (h *FakeHost) Exec() agent.Exec
- func (h *FakeHost) FS() agent.FS
- func (h *FakeHost) Facts() agent.Facts
- func (h *FakeHost) Get(p string) ([]byte, bool)
- func (h *FakeHost) Load(dir, dest string) error
- func (h *FakeHost) Locks() agent.Locks
- func (h *FakeHost) Log() *slog.Logger
- func (h *FakeHost) Path() agent.Path
- func (h *FakeHost) Paths() []string
- func (h *FakeHost) Procs() agent.Procs
- func (h *FakeHost) Put(p string, data []byte, mtime time.Time)
- func (h *FakeHost) SetEnv(k, v string)
Constants ¶
const LineageSuffix = ".hopsesh.json"
LineageSuffix is the core's lineage manifest name beside a session's main file; agents must ignore such files.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type FakeHost ¶
type FakeHost struct {
// Programs answer Exec.Run by binary name (argv[0] after resolution is the fake path
// "/bin/<name>").
Programs map[string]func(argv []string, o agent.RunOptions) agent.Result
// LocksHeld and PIDs simulate lock files and processes; LockHolders and PIDNames say
// which process holds a lock and what it is (a terminated process releases its locks).
LocksHeld map[string]bool
PIDs map[int]bool
LockHolders map[string][]int
PIDNames map[int]string
// Writes records every write, in order.
Writes []string
// contains filtered or unexported fields
}
FakeHost is an in-memory POSIX machine.
func NewFakeHost ¶
NewFakeHost returns an empty machine with the given home folder.