Skip to main content

go-table-tests

Write idiomatic table-driven Go tests that stay offline and follow this repo's conventions.

跳到安装

来源信息

仓库
stacklok/mecatl
最近来源活动
2026年5月29日 16:05
检测到的 SKILL.md 语言
英语
星标
119
分支
10

安装方式

默认使用会先检查来源的 Prompt;你也可以切换为直接命令,或下载本地副本。

检查来源文件

决定是否安装前,请先阅读 SKILL.md,以及 SkillsMP 当前展示的配套文件。

正在显示 SKILL.md

SKILL.md
来源说明 · 只读预览
name
go-table-tests
description
Write idiomatic table-driven Go tests that stay offline and follow this repo's conventions.
# Go table-driven tests When adding tests in this codebase: 1. **Stay offline.** Use `mockllm` + `memfs` (or a `t.TempDir()` for file-backed adapters). Never hit a live model or the network in a test. 2. **Prefer table-driven cases** for any behaviour with multiple inputs: ```go func TestThing(t *testing.T) { cases := []struct { name string in string want string }{ {name: "empty", in: "", want: ""}, {name: "basic", in: "x", want: "X"}, } for _, tc := range cases { t.Run(tc.name, func(t *testing.T) { if got := Thing(tc.in); got != tc.want { t.Errorf("Thing(%q) = %q, want %q", tc.in, got, tc.want) } }) } } ``` 3. **Assert error results, not panics.** Tool-level failures come back as an error `ToolResult` (`res.IsError`), not a Go error — check the result. 4. Run the suite with `task test` (which uses `-race`).
在 GitHub 查看