Documentation
¶
Overview ¶
Package agenttest holds test doubles for code built on package agent: a Store that counts its round trips (CountingStore).
Index ¶
- type CountingStore
- func (s *CountingStore) Counts() Counts
- func (s *CountingStore) Get(ctx context.Context, runID, name string) (agent.Entry, bool, error)
- func (s *CountingStore) Insert(ctx context.Context, runID, name string, data []byte) (agent.Entry, bool, error)
- func (s *CountingStore) Load(ctx context.Context, runID string, after int64) iter.Seq2[agent.Entry, error]
- func (s *CountingStore) Reset() Counts
- func (s *CountingStore) Unwrap() agent.Store
- type Counts
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) 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.