Documentation
¶
Overview ¶
Package profilefixture builds the controlled environment that profile-resolution parity tests require: a known AGENTDECK_PROFILE, CLAUDE_CONFIG_DIR, agent-deck config-dir override, and isolated tempdir.
It implements the harness from TEST-PLAN.md §6.3 and TUI-TEST-PLAN.md §6.7 (profileFixture). The five-way probe and AssertParity are transport-agnostic — callers pass closures that exercise CLI, web /api/settings, web /api/profiles, /healthz, and a TUI snapshot.
Usage:
f := profilefixture.New(t, profilefixture.Options{EnvProfile: "work"})
f.AssertParity(t, profilefixture.Probes{
CLI: func() string { return cliJSON("list").Profile },
WebAPI: func() string { return getJSON("/api/settings").Profile },
WebProfile: func() string { return getJSON("/api/profiles").Current },
Healthz: func() string { return getJSON("/healthz").Profile },
TUI: func() string { return tuiSnapshot.Profile },
})
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Fixture ¶
Fixture is the active test scaffold. Cleanup is registered via t.Cleanup automatically.
func New ¶
New seeds env vars and on-disk state, returning a Fixture. All originals are restored by t.Cleanup.
func (*Fixture) AssertParity ¶
AssertParity runs Probe and fails the test if any two probes return different values. The failure message lists every probe so the diagnosis is one glance.
type Options ¶
type Options struct {
// EnvProfile, if non-empty, sets AGENTDECK_PROFILE. Highest precedence
// in session.GetEffectiveProfile.
EnvProfile string
// ClaudeConfigDir, if non-empty, sets CLAUDE_CONFIG_DIR. Used to
// exercise the "infer profile from claude config dir" branch.
ClaudeConfigDir string
// ConfigDefault, if non-empty, writes a config file at
// <Home>/.agent-deck/config.json with `default_profile` set to this
// value. Lowest precedence — only matters when env / inference are
// both empty.
ConfigDefault string
// AgentDeckHome overrides the agent-deck config root via HOME. If
// empty, a fresh t.TempDir() is used so the test never touches the
// developer's real ~/.agent-deck.
AgentDeckHome string
}
Options controls how the fixture seeds the environment.
type Probes ¶
type Probes struct {
CLI func() string // `agent-deck list --json | .profile`
WebAPI func() string // `GET /api/settings | .profile`
WebProfile func() string // `GET /api/profiles | .current`
Healthz func() string // `GET /healthz | .profile`
TUI func() string // tuitest snapshot's profile field
}
Probes is the five-way probe suite from §6.7. Each field is a thunk that returns the profile string the relevant surface reports. Tests pass concrete closures bound to live CLI / HTTP clients / TUI models.
Any field left nil is skipped during AssertParity (so a unit test can exercise a subset of surfaces).