一键导入
fuku-add-test
Write a fuku test using table-driven tests with the mocks-once-at-top pattern. Use when adding tests, refactoring tests, or fixing failing tests.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Write a fuku test using table-driven tests with the mocks-once-at-top pattern. Use when adding tests, refactoring tests, or fixing failing tests.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
Reference for fuku.yaml configuration format — services, tiers, profiles, concurrency, retry, logs, watch. Use when editing fuku.yaml, adding a service, or explaining a config field.
Generate or regenerate a gomock mock for an interface in the fuku repo. Use when adding a new interface, modifying an existing one, or when tests fail due to stale mocks.
Run the full fuku verification loop (format, lint, vet, test, race, e2e) before committing. Use when asked to verify changes, run lint, run tests, check that changes pass CI, or before any commit/push.
| name | fuku-add-test |
| description | Write a fuku test using table-driven tests with the mocks-once-at-top pattern. Use when adding tests, refactoring tests, or fixing failing tests. |
t.Run() blocks in a single test function — if you have multiple cases, use TDT.Test_<MethodName>_<TestCase> (e.g. Test_Load_ExplicitPathNotFound).testify for assertions.go.uber.org/mock (mockgen) — never testify/mock. See fuku-generate-mock.before per casefunc Test_Example(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
mockDep := NewMockDependency(ctrl)
subject := &Implementation{dep: mockDep}
tests := []struct {
name string
before func()
input string
expect bool
}{
{
name: "success case",
input: "test-input",
before: func() {
mockDep.EXPECT().Method("test-input").Return(nil)
},
expect: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
tt.before()
result := subject.TestMethod(tt.input)
assert.Equal(t, tt.expect, result)
})
}
}
Always multi-line, one field per line:
// GOOD
{
name: "test case",
input: "value",
expected: true,
},
// BAD — never inline
{name: "test case", input: "value", expected: true},
*_test.go file matching the source file name; do not create a new file when one already exists.package runner, not runner_test).assert.Error(t, err) before assert.Nil(t, result).t.Run("description") already says what the case does.t.Skip(...) and a descriptive message.expectedExit and expectedError.help, --help, -h).