Help us shape the future of Go! Take the 2026 Go Developer Survey

agenttest

package
v0.10.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: 4 Imported by: 0

Documentation

Overview

Package agenttest holds test doubles for code built on package agent: a Store that counts its round trips (CountingStore).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CountingStore

type CountingStore struct {
	// contains filtered or unexported fields
}

CountingStore wraps a Store and counts the round trips it serves, for tests that hold the engine to a budget of store calls per operation. It passes run IDs and names through unchanged, so it implements Unwrap, and agent.Capability finds the wrapped store's Lister and Leaser through it (their calls are not counted).

func NewCountingStore

func NewCountingStore(inner agent.Store) *CountingStore

NewCountingStore returns a CountingStore over inner.

func (*CountingStore) Counts

func (s *CountingStore) Counts() Counts

Counts returns the counts so far.

func (*CountingStore) Get

func (s *CountingStore) Get(ctx context.Context, runID, name string) (agent.Entry, bool, error)

Get implements agent.Store.

func (*CountingStore) Insert

func (s *CountingStore) Insert(ctx context.Context, runID, name string, data []byte) (agent.Entry, bool, error)

Insert implements agent.Store.

func (*CountingStore) Load

func (s *CountingStore) Load(ctx context.Context, runID string, after int64) iter.Seq2[agent.Entry, error]

Load implements agent.Store.

func (*CountingStore) Reset

func (s *CountingStore) Reset() Counts

Reset zeroes the counts and returns the ones it cleared.

func (*CountingStore) Unwrap

func (s *CountingStore) Unwrap() agent.Store

Unwrap returns the wrapped store.

type Counts

type Counts struct {
	Insert, Get, Load int
	// Inserted is how many Inserts stored their entry (the rest found one already there).
	Inserted int
	// EntriesRead is how many entries every Load yielded, in all.
	EntriesRead int
	// Names lists the name of every Insert and Get, in order, as "insert <name>" or "get <name>".
	Names []string
}

Counts is how many round trips a CountingStore served, and how many entries its Loads yielded.

Jump to

Keyboard shortcuts

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