chattest

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package chattest builds a registered clone with a saved review whose agent session was kept, and a scripted agent, for tests of chats.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Answer

func Answer(markdown string, citations ...chat.Citation) []byte

Answer is an answer document.

func SessionID

func SessionID(n int) string

SessionID is the n-th session id the fake agent hands out.

Types

type Agent

type Agent struct {
	generatetest.Backend

	Reply func(request agent.Request, n int) (agent.Result, error)
	// contains filtered or unexported fields
}

Agent is a scripted Claude Code or Codex: Reply, when set, answers each request (n counts from 0); by default it answers "ok" citing README.md line 1, hands a forked or new session a fresh id and a resumed one its own.

func (*Agent) Default

func (a *Agent) Default(request agent.Request) agent.Result

Default is the default reply to request.

type Fixture

type Fixture struct {
	Registry  *repos.Registry
	Clone     repos.Clone
	Store     *store.Store
	Key       store.Key
	Root      string
	ReviewDir string
	SessionID string
	Head      string
	Agent     *Agent
	Service   *chat.Service
}

Fixture is a registered clone of acme/demo with review version 1 of pull request 7 saved, written by Backend, whose session SessionID was kept in ReviewDir under Root. ReviewDir's head/ holds README.md (one line) and src/app.go (five lines). The clone's pull request head holds README.md too, so a seeded session can cite it.

func New

func New(t *testing.T, o Options) *Fixture

New builds the fixture. It points CLAUDE_CONFIG_DIR and CODEX_HOME at empty directories.

func (*Fixture) Ask

func (f *Fixture) Ask(t *testing.T, conversation, question string) chat.Begun

Ask stores a question as a turn of a new conversation (conversation empty) or of conversation, failing the test on an error.

func (*Fixture) Conversation

func (f *Fixture) Conversation(t *testing.T, id string) store.Conversation

Conversation reads a conversation back.

type Options

type Options struct {
	// Backend is the review's harness; empty is claude.
	Backend string
	// NoSession stores the review without a kept session.
	NoSession bool
	// Hunk gives the review its base and merge base and indexes the pull
	// request's config/settings.env hunk, which adds the assembletest
	// PlantedSecret, without its diff, as the store keeps it.
	Hunk bool
}

Options vary the fixture.

Jump to

Keyboard shortcuts

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