用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/konflux-ci/qe-tools --skill running-tests命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
Use when adding a new CLI subcommand to qe-tools, or when understanding the pattern existing commands follow
Use when confused by CI behavior, investigating why a workflow failed, or troubleshooting environment variable issues in qe-tools
Use when debugging qe-tools commands locally, investigating panics or unexpected output, or setting up a local development environment
基于 SOC 职业分类
正在显示 SKILL.md
| name | running-tests |
| description | Use when running, writing, or troubleshooting unit tests for qe-tools commands or packages |
All tests are Go unit tests using stdlib testing. Tests live next to source (foo.go -> foo_test.go). External APIs (GitHub, Slack, Quay) are always mocked -- no live services needed.
make lint / make fmt)| Action | Command |
|---|---|
| Run all tests | make test |
| Run single package | go test ./cmd/prowjob/... -v |
| Run single test | go test ./cmd/prowjob/... -v -run TestConstructMessage |
| Run with race detector | make cover |
| Check coverage | go test ./... -coverprofile=coverage.out && go tool cover -html=coverage.out |
Test file goes next to the source it tests:
cmd/mycommand/
mycommand.go # Command implementation
mycommand_test.go # Tests for this command
pkg/mypackage/
mypackage.go # Library code
mypackage_test.go # Tests for this package
func TestMyFunction(t *testing.T) {
tests := []struct {
name string
input string
want string
wantErr bool
}{
{name: "valid input", input: "hello", want: "HELLO", wantErr: false},
{name: "empty input", input: "", want: "", wantErr: true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := MyFunction(tt.input)
if (err != nil) != tt.wantErr {
t.Errorf("error = %v, wantErr %v", err, tt.wantErr)
return
}
if got != tt.want {
t.Errorf("got %q, want %q", got, tt.want)
}
})
}
}
See cmd/estimate/reviewTime_test.go for the exemplar: uses go-github types directly in table-driven tests, mocks PR file lists with github.CommitFile structs, and tests both the estimation formula and label classification without calling GitHub.
For commands calling Slack or OCI registries, define an interface around the external call, implement a mock struct, and inject it in tests.
Reference test file: cmd/estimate/reviewTime_test.go -- table-driven, covers file extension mapping, estimation formula, label classification, and command registration. Shows the pattern for testing a command with GitHub API types without calling real services.
| Mistake | Fix |
|---|---|
| Testing only the happy path | Always include negative/edge cases (nil, empty, error) |
| Calling real APIs in tests | Mock everything external via interfaces |
| Skipping tests for bug fixes | Every fix needs a regression test proving it works |
| Not testing regex match safety | Test with input that doesn't match the pattern (see constructMessage in periodicSlackReport.go) |
Forgetting to run make test | Always verify all tests pass before finishing |