write-go-tests
Use when adding or extending Go tests in strike-cli — *_test.go, table-driven cases, fixtures, httptest, tool Ask helpers, TUI harnesses, coverage gaps. Do not use for running tests only (use test-and-validate).
- License 许可
- MIT
- 最近更新
- 2026-11-11
- Stars
- ★ 2
- Forks
- 0
01 前言 Front Matter
- name
- write-go-tests
- description
- Use when adding or extending Go tests in strike-cli — *_test.go, table-driven cases, fixtures, httptest, tool Ask helpers, TUI harnesses, coverage gaps. Do not use for running tests only (use test-and-validate).
02 资源文件 3
- 许可证LICENSE1.0 KB
- 参考文档SOURCE.md417 B
- 参考文档TRUST.auto.yaml2.2 KB
03 SKILL.md 正文
Write Go tests (strike-cli)
Tests only. Never modify production code; if code is untestable or buggy, report it.
Conventions
- Framework: stdlib
testingonly. - Placement:
package footests beside source asfoo_test.go(same package is fine and preferred for unexported helpers). - Style: table-driven where multiple inputs matter; plain functions for stateful sequences.
- Isolation:
t.TempDir(),t.Setenv, never touch real~/.strikeor network withouthttptest. - Assert observable behavior (return values, files written, events emitted, errors), not private call graphs.
- Bug fixes: add at least one regression test that fails before the fix when feasible.
Helpers by domain
Tools (internal/tool)
func allowAll(dir string) *Context {
return &Context{
WorkDir: dir, // usually t.TempDir()
Ask: func(ctx context.Context, req AskRequest) error { return nil },
}
}
Cover where relevant: happy path, invalid JSON args, permission rejection via Ask error,
path relative/absolute, workspace sandbox escape attempts, filestate stale read after
external change, truncation/output caps, deferred/toolsearch registration.
Tool surface is large (read/glob/grep/edit/write/apply_patch/bash + sandbox, task*, webfetch, todo*, memory_, issue_, notebook_edit, sleep, skill, question, plan_mode, phase_done, toolsearch, …). Prefer tests next to the module you touch; do not assume a fixed “six tools” list.
Permissions (internal/permission)
Evaluatelast-match-wins across layered rulesets.Service.Ask+Reply: once, always (session grant + sibling resolve), reject cascade, ctx cancel.
Protocol / session
- Round-trip event types through
protocol.Wrap→Envelope.Decodewhen adding kinds. - Session:
Open→Append→Close→Replay; malformed line errors.
Providers
- Prefer
httptest.NewServeragainstinternal/provider/baseand concrete adapters. - Engine integration:
internal/provider/echo(prompts starting withrunemit bash tool calls).
Config / auth
- Point HOME at
t.TempDir()so GlobalPath/cache paths stay sandboxed. - Auth store must stay mode
0600.
TUI
Source lives under internal/tui/_src/ and is flattened into internal/tui via
go generate ./internal/tui. Tests may live beside _src or as generated/package
tests under internal/tui.
Reuse helpers from internal/tui/_src/app/app_test.go (same package after generate),
including: updateApp, runAppCmd, runAllAppCmds, receiveAppOp, assertNoAppOp.
Shared support also appears under internal/tui/_src/test/ (e.g. testsupport_test.go).
Load skill tui-components before asserting chrome/theme behavior.
After writing
go test ./path/to/package/ -count=1 -v
# then tier gate — load test-and-validate
Priority gaps (fill these first when expanding coverage)
internal/tool— sandbox/workspace, filestate freshness, caps, defer/toolsearchinternal/engine— prune/compaction, interrupt, deferred tool re-promote, multi-toolinternal/permission— Evaluate + Service edge casesinternal/protocol+internal/session— new event kinds, replayinternal/question— multi-question ask/replyinternal/auth— OAuth/PKCE/device, resolve edge casesinternal/provider/*— SSE cancel, cache headers where applicableinternal/tui— keymap/default binds, modals, interrupt/esc paths
Platform notes
- Compare canonical paths with
filepath.EvalSymlinkswhen asserting absolute paths (macOS/var→/private/var). - Filesystem mtime granularity: sleep or content-change strategies when testing staleness.
04 同仓库更多 Skills
afk-implement
Run an unattended ("AFK") implementation session as the supervisor — scope small progressive iterations, push feature branches, open pull requests, drive review waves to clean, and never merge. Use when the user says they are going AFK or to bed, asks for overnight autonomous implementation, says "don't block on me", "open PRs but don't merge", "progressive adoption", or "stack changes".
protocol
Aura protocol reference documentation — 12-phase workflow, agent roles, constraints, and coding standards. Read when you need to understand the full workflow or look up conventions.
protocol
暂无简介
example
暂无简介
example
暂无简介
example
暂无简介