agentproxytest

package
v1.165.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package agentproxytest fakes the DigitalOcean Hosted Agents session HTTP API (see github.com/digitalocean/godo's hosted_agents.go) behind an httptest.Server, so agentproxy tests can drive a real do.HostedAgentsService end to end without a live harness backend.

Nothing outside this package's own tests (or other packages' _test.go files) should ever import it: it's test scaffolding, not production code, even though it lives in an ordinary buildable package rather than a _test.go file — that's what lets other packages' tests (e.g. internal/agentproxy/codex's) import it across package boundaries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	// Type is the wire "type" discriminator, e.g. "run.started",
	// "run.token_delta", "run.completed", "run.failed".
	Type string
	// Data is the event-specific payload. A nil Data marshals as "{}".
	Data json.RawMessage
}

Event is one canned SSE event the harness streams back from GET /v2/agents/sessions/{id}/stream, matching the event-specific part of godo.HostedAgentEvent's wire shape (see HostedAgentEventKind's doc comment for the canonical type strings).

type Harness

type Harness struct {
	Server *httptest.Server
	// contains filtered or unexported fields
}

Harness fakes the four Hosted Agents session routes an agentproxy test needs: session lookup, SSE stream, send-input, and HITL resolve. Point a *godo.Client at it with godo.SetBaseURL(h.Server.URL+"/") — do's NewHostedAgentsService wraps that client directly, so a Facade built against it talks to this harness exactly as it would a real backend.

func New

func New(t *testing.T, sessionID string) *Harness

New starts the fake harness and registers its shutdown via t.Cleanup. sessionID is the session id every route responds under — a test's Facade.SessionID should match it.

func (*Harness) QueueRun

func (h *Harness) QueueRun(runID string, events ...Event)

QueueRun arranges for the next POST .../input call to return runID, and for GET .../stream to then emit events (in order, tagged with runID), flushing after each one so a concurrent reader observes them incrementally rather than all at once at EOF.

One (runID, events) pair is enough for a single-turn sequence test; queue again before the next turn/start if a future test drives more than one turn over the same harness.

Jump to

Keyboard shortcuts

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