testkit

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 10 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 testkit builds a demo home for tests and the browser test server: a git repository, Claude Code sessions, Codex threads and OpenCode sessions from the agents' fixtures, with paths pointed at it. It is test infrastructure, not part of hopsesh.

Index

Constants

This section is empty.

Variables

View Source
var AgentVars = []string{"CLAUDE_CONFIG_DIR", "CODEX_HOME", "XDG_DATA_HOME", "XDG_CONFIG_HOME", "XDG_STATE_HOME",
	"XDG_CACHE_HOME", "OPENCODE_CONFIG_DIR", "OPENCODE_DB"}

AgentVars are the variables that point the agents at their data. A test that builds its own environment from this process's must not pass them on: on a machine that sets them, hopsesh under test would read (and run the agents on) the machine's real sessions.

View Source
var DemoOpenCode = []string{
	"ses_e29aa1ec8ffes7x6RCUekHyBbf",
	"ses_e29a8385effeUhBGvRVeVFrDLo",
	"ses_e29a5465fffek5VRD43HVvlx4P",
}

DemoOpenCode are the OpenCode sessions of the demo home, from the 2.3.0 sandbox capture: a short one, one with a subagent (its child session is counted, not listed) and one whose reply is in session_part rows.

Functions

func Apply added in v0.9.0

func Apply(env map[string]string)

Apply sets env in this process, unsetting the variables whose value is empty.

func DemoHome

func DemoHome(h string) error

DemoHome fills h (which should be empty) with a repository at git/demo whose remote is github.com/example/demo, Claude Code 2.1.284 sessions, Codex 0.153.2 threads and OpenCode 2.3.0 sessions (DemoOpenCode) in it.

func Env

func Env(h string) map[string]string

Env is the environment that points hopsesh and the agents at a demo home h: its own configuration, this machine named "studio", Tailscale left out of discovery, and (outside Windows) a PATH of system folders only, so no real agent program runs. A variable with an empty value is one to unset: Setenv, Apply and Environ do. (OpenCode reads an empty OPENCODE_DB as set: the data folder itself, which no database opens.)

func Environ added in v0.9.0

func Environ(base []string, env map[string]string) []string

Environ is base ("NAME=value" entries, as os.Environ gives them) with env applied: its variables replaced, and those whose value is empty left out.

func OpenCodeEnv added in v0.9.0

func OpenCodeEnv(dir string) map[string]string

OpenCodeEnv points OpenCode's folders into dir, for a test that keeps this machine's home: OpenCode's data, state and cache under dir, its configuration in dir/config, and OPENCODE_DB unset. Use it with Environ, or Setenv.

func Setenv added in v0.9.0

func Setenv(t interface{ Setenv(k, v string) }, env map[string]string)

Setenv sets env in a test's environment (t.Setenv, restored after the test), unsetting the variables whose value is empty.

func UnsetAgentEnv added in v0.9.0

func UnsetAgentEnv(t interface{ Setenv(k, v string) })

UnsetAgentEnv unsets AgentVars for a test (restored after it), for a test with a home of its own: the agents then keep their data under that home. Set the variables a test wants after calling it.

Types

This section is empty.

Directories

Path Synopsis
Package dbagent is a stand-in agent that keeps its sessions in SQLite, as OpenCode does, for the core's tests: it lists and reads them with the Host's SQL, its bundle file is virtual (Materializer), only its own program writes the database (here, in the test's process), installs go through that program (VendorInstaller), and undo reaches it through SessionStore.
Package dbagent is a stand-in agent that keeps its sessions in SQLite, as OpenCode does, for the core's tests: it lists and reads them with the Host's SQL, its bundle file is virtual (Materializer), only its own program writes the database (here, in the test's process), installs go through that program (VendorInstaller), and undo reaches it through SessionStore.
Package fakeagent is the stand-in Claude Code, Codex and OpenCode the tests (and the Windows screenshots in CI) run in place of the real agents.
Package fakeagent is the stand-in Claude Code, Codex and OpenCode the tests (and the Windows screenshots in CI) run in place of the real agents.
Package fakecloud is the stand-in for the vendors' clouds that the tests run against: cloud sessions kept as JSON files in $FAKE_CLOUD_DIR, a local bare repository standing in for the GitHub repository the clouds clone and push, the cloud verbs of the stand-in claude and codex programs (see internal/testkit/fakeagent), a small third-party-style cloud CLI of its own (`fakecloud remote …`, driven by Stub), and `fakecloud work <id>`, which plays the cloud agent.
Package fakecloud is the stand-in for the vendors' clouds that the tests run against: cloud sessions kept as JSON files in $FAKE_CLOUD_DIR, a local bare repository standing in for the GitHub repository the clouds clone and push, the cloud verbs of the stand-in claude and codex programs (see internal/testkit/fakeagent), a small third-party-style cloud CLI of its own (`fakecloud remote …`, driven by Stub), and `fakecloud work <id>`, which plays the cloud agent.
Package fakeopencode is the stand-in OpenCode 2.3.0 the tests (and the test bundle) run in place of the real one.
Package fakeopencode is the stand-in OpenCode 2.3.0 the tests (and the test bundle) run in place of the real one.
Package termfake is a stand-in program for the terminal's tests: it runs in a tab, asks the terminal what it is (DA1 and DA2, as Claude Code does), says what came back, and then does what keys ask, so a test can drive a tab end to end through the real window.
Package termfake is a stand-in program for the terminal's tests: it runs in a tab, asks the terminal what it is (DA1 and DA2, as Claude Code does), says what came back, and then does what keys ask, so a test can drive a tab end to end through the real window.
Package thirdagent is a stand-in third local agent for the tests: a module with more than one root, account folders, a desktop app and a writer, that is neither Claude Code nor Codex.
Package thirdagent is a stand-in third local agent for the tests: a module with more than one root, account folders, a desktop app and a writer, that is neither Claude Code nor Codex.

Jump to

Keyboard shortcuts

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