derivetest

package
v0.3.0 Latest Latest
Warning

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

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

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package derivetest is test support for the derive engine: it stores raw data as ingest would and inspects the derived tables.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func APIError

func APIError(ts string, kv ...any) string

APIError is a synthetic assistant error line.

func At

func At(sec int) string

At returns the timestamp 2026-11-01T10:00:00.000Z plus sec seconds.

func Cwd

func Cwd(line, cwd string) string

Cwd sets the cwd of a line.

func Line

func Line(typ, ts string, kv ...any) string

Line builds a base line of the given type; kv pairs override or extend the defaults.

func Notify

func Notify(ts, toolUseID string, ms int) string

Notify is a queue-operation enqueue carrying a task notification.

func Prompt

func Prompt(ts, text string) string

Prompt is a typed human prompt.

func Reply

func Reply(ts, msgID, model string, usage map[string]any, blocks ...map[string]any) string

Reply is an assistant line.

func Result

func Result(ts, toolUseID string, isError bool, toolUseResult map[string]any) string

Result is a user line with one tool_result block.

func Side

func Side(line, agentID string) string

Side marks a line as a subagent line.

func SidePrompt

func SidePrompt(ts, text string) string

SidePrompt is the first user line of a subagent.

func TaskNote

func TaskNote(ts string) string

TaskNote is the user line Claude Code writes when a background task reports back.

func Text

func Text(s string) map[string]any

Text is a text content block.

func Tool

func Tool(id, name string, input map[string]any) map[string]any

Tool is a tool_use content block.

func Turn

func Turn(ts string, ms int) string

Turn is a system/turn_duration line.

func Unix

func Unix(sec int) int64

Unix returns the epoch seconds of At(sec).

func Usage

func Usage(in, out, read, w5, w1 int) map[string]any

Usage builds a usage object.

Types

type Env

type Env struct {
	Owner, App string
	DB         *db.DB
}

Env is a migrated test database with an application pool.

func New

func New(t testing.TB) *Env

New creates a fresh database.

func Wrap

func Wrap(t testing.TB, ownerURL, appURL string) *Env

Wrap uses an existing database.

func (*Env) Derive

func (e *Env) Derive(t testing.TB, userID string, batch int) int

Derive runs DeriveUser with the given batch size (0 = default) and returns the rows processed.

func (*Env) Device

func (e *Env) Device(t testing.TB, userID, name string) string

Device inserts a device and returns its id.

func (*Env) Dump

func (e *Env) Dump(t testing.TB, userID string, repl map[string]string) string

Dump is the canonical text of all derived tables of the user, with every key of repl replaced by its value.

func (*Env) Exec

func (e *Env) Exec(t testing.TB, q string, args ...any)

Exec runs a statement as the database owner.

func (*Env) N

func (e *Env) N(t testing.TB, q string, args ...any) int

N runs an owner query returning one integer.

func (*Env) Put

func (e *Env) Put(t testing.TB, userID, deviceID string, files ...File)

Put stores files as ingest would, as owner (bypasses RLS).

func (*Env) Reset

func (e *Env) Reset(t testing.TB, userID string)

Reset deletes the derived rows and cursors of the user.

func (*Env) Row

func (e *Env) Row(t testing.TB, q string, args ...any) string

Row runs an owner query and joins the first row's values with "|".

func (*Env) User

func (e *Env) User(t testing.TB, sub string) string

User inserts a user and returns its id.

type File

type File struct {
	Rel   string
	Lines []string
	JSON  string
}

File is one file to store: Lines for an append file, JSON for a snapshot file.

func Scenario

func Scenario() []File

Scenario returns the files of one session "g1" (main + 3 subagents incl. a nested one) in a fixed order.

Jump to

Keyboard shortcuts

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