testutil

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// WaitLong is the default timeout for test operations that may take a while
	// (e.g. integration tests with HTTP round-trips).
	WaitLong = 30 * time.Second

	// WaitMedium is a timeout for moderately slow operations.
	WaitMedium = 10 * time.Second

	// WaitShort is a timeout for operations expected to complete quickly.
	WaitShort = 5 * time.Second

	// IntervalFast is a short polling interval for require.Eventually and similar.
	IntervalFast = 50 * time.Millisecond
)

Shared test timeout and interval constants. Using named constants avoids magic numbers and makes timeout policy easy to adjust across the entire test suite.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockProvider added in v1.0.1

type MockProvider struct {
	NameStr         string
	URL             string
	Bridged         []string
	Passthrough     []string
	InterceptorFunc func(w http.ResponseWriter, r *http.Request, tracer trace.Tracer) (intercept.Interceptor, error)
}

func (*MockProvider) APIDumpDir added in v1.1.0

func (*MockProvider) APIDumpDir() string

func (*MockProvider) AuthHeader added in v1.0.1

func (*MockProvider) AuthHeader() string

func (*MockProvider) BaseURL added in v1.0.1

func (m *MockProvider) BaseURL() string

func (*MockProvider) BridgedRoutes added in v1.0.1

func (m *MockProvider) BridgedRoutes() []string

func (*MockProvider) CircuitBreakerConfig added in v1.0.1

func (*MockProvider) CircuitBreakerConfig() *config.CircuitBreaker

func (*MockProvider) CreateInterceptor added in v1.0.1

func (m *MockProvider) CreateInterceptor(w http.ResponseWriter, r *http.Request, tracer trace.Tracer) (intercept.Interceptor, error)

func (*MockProvider) InjectAuthHeader added in v1.0.1

func (*MockProvider) InjectAuthHeader(_ *http.Header)

func (*MockProvider) Name added in v1.0.1

func (m *MockProvider) Name() string

func (*MockProvider) PassthroughRoutes added in v1.0.1

func (m *MockProvider) PassthroughRoutes() []string

func (*MockProvider) RoutePrefix added in v1.0.3

func (m *MockProvider) RoutePrefix() string

func (*MockProvider) Type added in v1.1.0

func (m *MockProvider) Type() string

type MockRecorder

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

MockRecorder is a test implementation of aibridge.Recorder that captures all recording calls for test assertions.

func (*MockRecorder) RecordInterception

func (m *MockRecorder) RecordInterception(_ context.Context, req *recorder.InterceptionRecord) error

func (*MockRecorder) RecordInterceptionEnded

func (m *MockRecorder) RecordInterceptionEnded(_ context.Context, req *recorder.InterceptionRecordEnded) error

func (*MockRecorder) RecordModelThought added in v1.1.0

func (m *MockRecorder) RecordModelThought(_ context.Context, req *recorder.ModelThoughtRecord) error

func (*MockRecorder) RecordPromptUsage

func (m *MockRecorder) RecordPromptUsage(_ context.Context, req *recorder.PromptUsageRecord) error

func (*MockRecorder) RecordTokenUsage

func (m *MockRecorder) RecordTokenUsage(_ context.Context, req *recorder.TokenUsageRecord) error

func (*MockRecorder) RecordToolUsage

func (m *MockRecorder) RecordToolUsage(_ context.Context, req *recorder.ToolUsageRecord) error

func (*MockRecorder) RecordedInterceptionEnd added in v1.1.0

func (m *MockRecorder) RecordedInterceptionEnd(id string) *recorder.InterceptionRecordEnded

RecordedInterceptionEnd returns the stored InterceptionRecordEnded for the given interception ID, or nil if not found.

func (*MockRecorder) RecordedInterceptions

func (m *MockRecorder) RecordedInterceptions() []*recorder.InterceptionRecord

RecordedInterceptions returns a copy of recorded interceptions in a thread-safe manner. Note: This is a shallow clone (see RecordedTokenUsages for details).

func (*MockRecorder) RecordedModelThoughts added in v1.1.0

func (m *MockRecorder) RecordedModelThoughts() []*recorder.ModelThoughtRecord

RecordedModelThoughts returns a copy of recorded model thoughts in a thread-safe manner. Note: This is a shallow clone (see RecordedTokenUsages for details).

func (*MockRecorder) RecordedPromptUsages

func (m *MockRecorder) RecordedPromptUsages() []*recorder.PromptUsageRecord

RecordedPromptUsages returns a copy of recorded prompt usages in a thread-safe manner. Note: This is a shallow clone (see RecordedTokenUsages for details).

func (*MockRecorder) RecordedTokenUsages

func (m *MockRecorder) RecordedTokenUsages() []*recorder.TokenUsageRecord

RecordedTokenUsages returns a copy of recorded token usages in a thread-safe manner. Note: This is a shallow clone - the slice is copied but the pointers reference the same underlying records. This is sufficient for our test assertions which only read the data and don't modify the records.

func (*MockRecorder) RecordedToolUsages

func (m *MockRecorder) RecordedToolUsages() []*recorder.ToolUsageRecord

RecordedToolUsages returns a copy of recorded tool usages in a thread-safe manner. Note: This is a shallow clone (see RecordedTokenUsages for details).

func (*MockRecorder) ToolUsages

func (m *MockRecorder) ToolUsages() []*recorder.ToolUsageRecord

ToolUsages returns the raw toolUsages slice for direct field access in tests. Use RecordedToolUsages() for thread-safe access when assertions don't need direct field access.

func (*MockRecorder) TotalCacheReadInputTokens added in v1.1.0

func (m *MockRecorder) TotalCacheReadInputTokens() int64

TotalCacheReadInputTokens returns the sum of cache read input tokens across all recorded token usages.

func (*MockRecorder) TotalCacheWriteInputTokens added in v1.1.0

func (m *MockRecorder) TotalCacheWriteInputTokens() int64

TotalCacheWriteInputTokens returns the sum of cache write input tokens across all recorded token usages.

func (*MockRecorder) TotalInputTokens added in v1.1.0

func (m *MockRecorder) TotalInputTokens() int64

TotalInputTokens returns the sum of input tokens across all recorded token usages.

func (*MockRecorder) TotalOutputTokens added in v1.1.0

func (m *MockRecorder) TotalOutputTokens() int64

TotalOutputTokens returns the sum of output tokens across all recorded token usages.

func (*MockRecorder) VerifyAllInterceptionsEnded

func (m *MockRecorder) VerifyAllInterceptionsEnded(t *testing.T)

VerifyAllInterceptionsEnded verifies all recorded interceptions have been marked as completed.

func (*MockRecorder) VerifyModelThoughtsRecorded added in v1.1.0

func (m *MockRecorder) VerifyModelThoughtsRecorded(t *testing.T, expected []recorder.ModelThoughtRecord)

Jump to

Keyboard shortcuts

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