agenttest

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: Apache-2.0 Imports: 18 Imported by: 1 module, 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 agenttest is the conformance kit for agent modules: an in-memory Host and a suite every module must pass.

Index

Constants

View Source
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

func Run

func Run(t *testing.T, m agent.Module, newHost func(t *testing.T) *FakeHost)

Run checks a module against the contract. newHost returns a machine with the module's test sessions on it (at least one), the agent's binary present and its roots resolved from the Spec's defaults.

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

func NewFakeHost(home string) *FakeHost

NewFakeHost returns an empty machine with the given home folder.

func (*FakeHost) AddBinary

func (h *FakeHost) AddBinary(name, versionLine string)

AddBinary makes a binary present with a version line.

func (*FakeHost) Exec

func (h *FakeHost) Exec() agent.Exec

func (*FakeHost) FS

func (h *FakeHost) FS() agent.FS

func (*FakeHost) Facts

func (h *FakeHost) Facts() agent.Facts

func (*FakeHost) Get

func (h *FakeHost) Get(p string) ([]byte, bool)

Get returns a file's content.

func (*FakeHost) Load

func (h *FakeHost) Load(dir, dest string) error

Load copies a folder from disk (test data) to dest, keeping relative paths.

func (*FakeHost) Locks

func (h *FakeHost) Locks() agent.Locks

func (*FakeHost) Log

func (h *FakeHost) Log() *slog.Logger

func (*FakeHost) Path

func (h *FakeHost) Path() agent.Path

func (*FakeHost) Paths

func (h *FakeHost) Paths() []string

Paths lists every file, sorted.

func (*FakeHost) Procs

func (h *FakeHost) Procs() agent.Procs

func (*FakeHost) Put

func (h *FakeHost) Put(p string, data []byte, mtime time.Time)

Put creates a file (and its folders) with a modification time.

func (*FakeHost) SetEnv

func (h *FakeHost) SetEnv(k, v string)

SetEnv sets a variable the module's Spec declares.

Jump to

Keyboard shortcuts

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