sessiontest

package
v1.35.0 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package sessiontest builds session events from terse JSON for the sessions test suites. Import it from _test files only.

Fixtures name events by their time: Ev(t, typ, 5200, …) has id "e5200" and is processed 5.2s after Epoch, so a tool result can point at its call by that number.

Index

Constants

This section is empty.

Variables

View Source
var Epoch = time.Date(2026, 1, 1, 14, 0, 0, 0, time.UTC)

Epoch is time zero for fixture timestamps.

Functions

func JS

func JS(s string) string

JS quotes s as a JSON string, escaping control bytes the way the wire does (%q would emit Go escapes JSON rejects).

func Result

func Result(useMS int, body string, isErr bool) string

Result is the fields of an agent.tool_result answering the call made at useMS.

func Text

func Text(s string) string

Text is a content field holding one text block.

func Tool

func Tool(name, input, extra string) string

Tool is the fields of an agent.tool_use calling name with input (raw JSON).

Types

type Event

Event is the wire event union the sessions packages consume.

func Canonical

func Canonical(t *testing.T) []Event

Canonical is the reference session fixture: a user request, then three model requests (thinking, text, tool calls) ending on a call awaiting approval.

func Ev

func Ev(t *testing.T, typ string, ms int, extra string) Event

Ev is a processed event of type typ with id "e<ms>", processed at Epoch+ms. extra is more JSON fields, without braces.

func Parse

func Parse(t *testing.T, js string) Event

Parse decodes one wire event, failing the test on bad JSON.

func Pending

func Pending(t *testing.T, typ, id, extra string) Event

Pending is an event the server has not processed: a queued user event or a streaming preview.

Jump to

Keyboard shortcuts

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