[testify-expert] Improve Test Quality: pkg/workflow/unquote_uses_test.go
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
首先阅读 pkg/workflow/unquote_uses_test.go 以及源文件 pkg/workflow/compiler_yaml_step_conversion.go,特别是 unquoteUsesWithComments 和 injectZizmorUnverifiedCreatorAnnotations。运行 go test ./pkg/workflow/ -run 'UnquoteUses|Zizmor' 建立基线,然后完成验收清单:将手动 t.Errorf 替换为 testify assert/require,添加缺失的 formatStepEnvValueForYAML 和 ConvertStepToYAML 用例,从 unverifiedCreatorActionPrefixes 生成前缀表,并重命名文件。完成的标准是 make test-unit 通过且所有新用例都已存在。
由索引模型根据 Issue 内容生成。
描述
Current State
- Test file:
pkg/workflow/unquote_uses_test.go(280 LOC, 4 test functions, 0assert/requireusages; all checks useif got != want { t.Errorf }) - Source file:
pkg/workflow/compiler_yaml_step_conversion.go(functions:injectZizmorUnverifiedCreatorAnnotations,ConvertStepToYAML,unquoteUsesWithComments,(*Compiler).renderStepFromMap,formatStepEnvValueForYAML)
Strengths
- Already table-driven with descriptive case names.
- Good edge cases for malformed/unclosed quotes and hash-without-space.
- Realistic multi-step YAML inputs.
Prioritized Improvements
1. Missing / high-value tests
injectZizmorUnverifiedCreatorAnnotationshas only 3 cases. Add:- every entry in
unverifiedCreatorActionPrefixes(iterate the slice so new prefixes are auto-covered), - a verified action (
actions/checkout@...) gets no annotation, - tab indentation and
- uses:(list-item form; currentlyTrimLeft+CutPrefix("uses: ")would NOT match- uses: safedep/..., so document or fix the expected behaviour), - a quoted value (
uses: "safedep/pmg@sha") — does it match the prefix?, - empty input and idempotency (running twice should not double-inject, or the test should pin that it does).
- every entry in
ConvertStepToYAMLandformatStepEnvValueForYAMLhave no direct tests in this file (only indirect ones incompiler_generation_test.go/multiline_test.go). Add a small table forformatStepEnvValueForYAML(string, bool, int, multi-line, string needing quoting) and aConvertStepToYAMLcase checking thatuseswith a# v6comment ends up unquoted end-to-end.unquoteUsesWithComments: add CRLF input,uses: 'single-quoted # v1', anduses: "..."with extra spaces. The "multiple quotes on same line" case pins a questionable behaviour; add a comment saying it is intentional.
2. Testify assertion upgrades
Before / after
// Before
if result != tt.expected {
t.Errorf("unquoteUsesWithComments() = %q, want %q", result, tt.expected)
}
// After
assert.Equal(t, tt.expected, unquoteUsesWithComments(tt.input), "unquoteUsesWithComments should produce expected YAML")
Add "github.com/stretchr/testify/assert" to imports; use require.NoError for ConvertStepToYAML errors. Replacing the multi-line Got/Want messages also yields better diffs.
3. Table-driven refactors
- The three
unquoteUsesWithCommentstests (TestUnquoteUsesWithComments,...EdgeCases,...RealWorldExamples) share an identical struct and loop. Merge into one table (or keep three with a shared helper) andt.Parallel()per subtest. - Build
unverifiedCreatorActionPrefixescases from the slice rather than hard-coding.
4. Organization / readability
- File name
unquote_uses_test.goalso testsinjectZizmorUnverifiedCreatorAnnotations; rename tocompiler_yaml_step_conversion_test.goto match the source file. - Use named raw-string constants for the repeated SHA pins to shorten cases.
Acceptance Checklist
- testify
assert/requireused instead of manualt.Errorfcomparisons - New tests for the gaps listed in section 1
- Tables merged / generated from
unverifiedCreatorActionPrefixes - File renamed to match source file
-
make test-unitpasses
Generated by 🧪 Daily Testify Uber Super Expert · copilot · auto · 15.3 AIC · ⌖ 9.64 AIC · ⊞ 7.3K · ◷
- expires on Oct 6, 2026, 10:22 AM UTC-08:00
- 主要语言
- Go
- 星标
- 5.4k
- 派生
- 584
- 平均合并
- 3 小时 16 分钟
- 30 天内合并 PR
- 826
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 提供 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
github/gh-aw 的其他 Issue
-
agent-research
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
cookie sergo
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
ai-inspected
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
goroutineresourceleak (81st linter): paren_unwrap_gap across lock/cancel/channel detection, day one未关闭cookie sergo
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
automation models
难度 1/5 1 小时以内 新手友好度 1/100
维护者通常 1 天内回复
相似的 Issue
-
documentation good first issue
难度 2/5 1-3 小时 新手友好度 90/100
维护者通常 1 天内回复
-
raised-by:reviewer
难度 1/5 1-3 小时 新手友好度 90/100
medici-finance/assay#3333 ·
维护者通常 1 天内回复
-
enhancement good first issue
难度 2/5 1-3 小时 新手友好度 88/100
onurbaydas/VirtoMir#9 ·
-
enhancement good first issue
难度 1/5 1 小时以内 新手友好度 95/100
syncronix-labs/aegora#12 ·
-
auto-fixable pkg:api
难度 2/5 1-3 小时 新手友好度 82/100
tphakala/birdnet-go#4650 · 2 条评论 · 1 个 reaction ·
维护者通常 1 天内回复