Documentation
¶
Overview ¶
Package agenttest provides agent environments, platform mocks, and caller contexts for tests of agents built on agentsdk.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithCaller ¶
WithCaller returns a context for an authenticated user with the given access. Identity does not determine access, so tests can model any valid combination.
Types ¶
type Env ¶
type Env struct {
Agent *agentsdk.Agent
// Airlock records calls made through the platform API.
Airlock *MockAirlock
// URL is the mock Airlock base URL.
URL string
}
Env is a fully constructed test agent with its mock Airlock server.
func New ¶
New invokes factory first while runtime environment is cleared, then provisions a mock Airlock and test database and starts the agent. Start opens the database, resolves and applies migrations from the enclosing Go module, synchronizes declarations, and runs named OnStart hooks before New returns. TEST_DB_URL is used when explicitly supplied; otherwise New starts a throwaway pgvector container. The factory may wire Agent.DB()'s late-bound handle, but database operations are unavailable until Start.
type MockAirlock ¶
type MockAirlock struct {
Server *httptest.Server
// LLMResponse is the NDJSON response returned by the model endpoint.
LLMResponse []byte
// contains filtered or unexported fields
}
MockAirlock is an in-process Airlock API used by agent tests.
func NewMockAirlock ¶
func NewMockAirlock() (*MockAirlock, string)
NewMockAirlock creates a mock Airlock server and returns its base URL.
func (*MockAirlock) Requests ¶
func (m *MockAirlock) Requests() []MockRequest
Requests returns all recorded requests.
func (*MockAirlock) RequestsByPath ¶
func (m *MockAirlock) RequestsByPath(prefix string) []MockRequest
RequestsByPath returns requests matching the path prefix.
type MockRequest ¶
MockRequest records a request made to the mock Airlock server.