recorder

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package recorder provides call recording (VCR pattern) for cloudemu services.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Call

type Call struct {
	Service   string
	Operation string
	Input     any
	Output    any
	Error     error
	Timestamp time.Time
	Duration  time.Duration
}

Call represents a recorded API call.

type Matcher

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

Matcher provides fluent test assertions for recorded calls.

func NewMatcher

func NewMatcher(t *testing.T, r *Recorder) *Matcher

NewMatcher creates a Matcher from a recorder.

func (*Matcher) AllErrored

func (m *Matcher) AllErrored() *Matcher

AllErrored asserts that all calls had errors.

func (*Matcher) Count

func (m *Matcher) Count(expected int) *Matcher

Count asserts the number of matching calls.

func (*Matcher) ForOperation

func (m *Matcher) ForOperation(op string) *Matcher

ForOperation filters calls by operation.

func (*Matcher) ForService

func (m *Matcher) ForService(service string) *Matcher

ForService filters calls by service.

func (*Matcher) HasCalls

func (m *Matcher) HasCalls() *Matcher

HasCalls asserts that there is at least one matching call.

func (*Matcher) NoCalls

func (m *Matcher) NoCalls() *Matcher

NoCalls asserts that there are no matching calls.

func (*Matcher) NoErrors

func (m *Matcher) NoErrors() *Matcher

NoErrors asserts that no calls had errors.

func (*Matcher) String

func (m *Matcher) String() string

String returns a summary of matched calls.

type Recorder

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

Recorder records API calls for later assertion.

func New

func New() *Recorder

New creates a new Recorder.

func (*Recorder) CallCount

func (r *Recorder) CallCount() int

CallCount returns the total number of recorded calls.

func (*Recorder) CallCountFor

func (r *Recorder) CallCountFor(service, operation string) int

CallCountFor returns the number of calls matching the given service and operation.

func (*Recorder) Calls

func (r *Recorder) Calls() []Call

Calls returns a copy of all recorded calls.

func (*Recorder) CallsFor

func (r *Recorder) CallsFor(service, operation string) []Call

CallsFor returns all calls matching the given service and operation.

func (*Recorder) LastCall

func (r *Recorder) LastCall() *Call

LastCall returns the most recent call, or nil if none.

func (*Recorder) Record

func (r *Recorder) Record(service, operation string, input, output any, err error, duration time.Duration)

Record records a call.

func (*Recorder) Reset

func (r *Recorder) Reset()

Reset clears all recorded calls.

Jump to

Keyboard shortcuts

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