[testify-expert] Improve Test Quality: pkg/workflow/safe_outputs_config_helpers_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
- 73/100
Hướng nghiên cứu
Đọc pkg/workflow/safe_outputs_config_helpers_test.go cùng với pkg/workflow/safe_outputs_config_helpers.go; bắt đầu bằng cách thêm các trường hợp trực tiếp cho buildNormalizedSortedJSON và các trường hợp dạng bảng cho buildCustomSafeOutputJobsJSON. Chuyển TestUsesPatchesAndCheckouts sang safe_outputs_runtime_test.go theo yêu cầu. Hoàn tất khi các mục trong checklist được bao phủ và make test-unit chạy thành công.
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/safe_outputs_config_helpers_test.go(178 LOC, 3 test functions) - Source pair:
pkg/workflow/safe_outputs_config_helpers.go(61 LOC;buildNormalizedSortedJSON,buildCustomSafeOutputJobsJSON) - Note:
TestUsesPatchesAndCheckoutstargetsusesPatchesAndCheckoutsinsafe_outputs_runtime.go, not this file's source.
Strengths
- Good table-driven
TestUsesPatchesAndCheckoutscovering nil, staged (global and per-handler), and mixed cases. - Uses
requirefor preconditions andassert.JSONEqfor JSON comparison.
Prioritized Improvements
1. Missing high-value tests
buildNormalizedSortedJSONhas no direct test. Add table-driven cases: empty/nilnames; name normalization (e.g."my-job"→my_job); duplicate names that normalize to the same key (collapse to one);valueFnreceiving the normalized name; deterministic output across repeated calls.buildCustomSafeOutputJobsJSON: add a case for a single job, a job name with uppercase or special characters, and anilJobsmap vs an empty map.- Move
TestUsesPatchesAndCheckoutsintosafe_outputs_runtime_test.goto match its source file.
2. Testify assertion upgrades
Details
- In
TestBuildCustomSafeOutputJobsJSON, the trailingjson.Unmarshal+assert.Empty(result[...])is redundant withassert.JSONEq. Replace it withassert.Len(t, result, 2)or drop it.assert.Emptyon a missing key also passes, so it proves nothing. TestBuildCustomSafeOutputJobsJSONEmpty: useassert.Equal(t, "", ...)with messages, or make it table-driven.- Add messages to assertions that lack them.
3. Table-driven refactors
Details
Before:
assert.Empty(t, buildCustomSafeOutputJobsJSON(&WorkflowData{SafeOutputs: &SafeOutputsConfig{}}))
assert.Empty(t, buildCustomSafeOutputJobsJSON(&WorkflowData{SafeOutputs: nil}))
After:
tests := []struct{ name string; data *WorkflowData; want string }{
{"nil safe outputs", &WorkflowData{}, ""},
{"empty jobs", &WorkflowData{SafeOutputs: &SafeOutputsConfig{}}, ""},
{"two jobs", &WorkflowData{SafeOutputs: &SafeOutputsConfig{Jobs: map[string]*SafeJobConfig{"z-job": {}, "a-job": {}}}}, `{"a_job":"","z_job":""}`},
}
Merge TestBuildCustomSafeOutputJobsJSON and ...Empty into one table with t.Run.
4. Organization/readability
Details
- Split file by source (runtime vs config helpers).
- Consider a small helper to build a staged
BaseSafeOutputConfigto cut repeatedtemplatableBoolPtr("true")literals.
Acceptance Checklist
- Add direct tests for
buildNormalizedSortedJSON - Merge the two
buildCustomSafeOutputJobsJSONtests into one table - Remove redundant unmarshal assertions
- Move
TestUsesPatchesAndCheckoutsnext to its source -
make test-unitpasses
Generated by 🧪 Daily Testify Uber Super Expert · copilot · auto (Claude Sonnet 5.5) · ~15 AIC · ⌖ ~1 AIC · ⊞ 9.5K · ◷
- expires on Nov 8, 2026, 10:05 AM UTC-08:00
- Ngôn ngữ chính
- Go
- Star
- 5.6k
- Fork
- 615
- Merge trung bình
- 5 giờ 51 phút
- Pull request đã merge (30 ngày)
- 793
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
-
agent-research
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
automated-analysis code-quality cookie refactoring
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
cookie dependencies go
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
automation cookie
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
agentic-workflows automation aw-essential cookie
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
Maintainer thường phản hồi trong vòng 1 ngày
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
microsoft/TypeScript#65370 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug tech debt testing
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
aws/amazon-vpc-cni-k8s#3976 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
txn2/mcp-data-platform#2522 ·
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 72/100
open-telemetry/opentelemetry-go-contrib#10234 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
discovery/backoff: default FindPeers limit yields no fresh peersCó thể đã có người làm @zakazaka95 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100