[testify-expert] Improve Test Quality: pkg/workflow/unquote_uses_test.go
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 72/100
Hướng nghiên cứu
Bắt đầu bằng cách đọc pkg/workflow/unquote_uses_test.go cùng với mã nguồn pkg/workflow/compiler_yaml_step_conversion.go, đặc biệt là unquoteUsesWithComments và injectZizmorUnverifiedCreatorAnnotations. Chạy go test ./pkg/workflow/ -run 'UnquoteUses|Zizmor' để thiết lập đường cơ sở, sau đó làm qua danh sách kiểm tra chấp nhận: thay t.Errorf thủ công bằng testify assert/require, thêm các trường hợp formatStepEnvValueForYAML và ConvertStepToYAML còn thiếu, tạo bảng tiền tố từ unverifiedCreatorActionPrefixes, và đổi tên tệp. Hoàn thành là khi make test-unit vượt qua với tất cả các trường hợp mới hiện có.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- Go
- Star
- 5.3k
- Fork
- 568
- Merge trung bình
- 8 giờ 50 phút
- Pull request đã merge (30 ngày)
- 721
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Có Dockerfile hoặc tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của github/gh-aw
-
ai-inspected
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
ai-inspected
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 1 ngày
-
automation code-quality cookie improvement quick-win task-mining
Độ khó 2/5 Dưới một giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
cookie maintenance step-naming
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
agentic-workflows automation code-quality cookie documentation improvement quick-win task-mining
Độ khó 2/5 Dưới một giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
Issue tương tự
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 90/100
FootprintAI/Containarium#2338 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
SagerNet/sing-openvpn#11 ·
-
priority: P3 type: devops
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
jiegui2025/hwspec#57 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
columnar-tech/dbc#513 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
streamplace/streamplace#1351 ·
Maintainer thường phản hồi trong vòng 2 ngày