[testify-expert] Improve Test Quality: pkg/cli/codemod_copilot_web_fetch_test.go

Đã đóng Phù hợp với người mới
#74,912 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@gh-aw-bot đang làm issue này rồi.

Từ ngày 6/11/2026.

  • #75298 của @copilot-swe-agent — đã merge

Đá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
Loại issue
Tái cấu trúc
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
github-actions, go
Lĩnh vực
testing

Hướng nghiên cứu

Đọc pkg/cli/codemod_copilot_web_fetch_test.go cùng với pkg/cli/codemod_copilot_web_fetch.go và pkg/cli/codemod_copilot_web_search_test.go liên quan. Bắt đầu với các trường hợp còn thiếu của isNestedWorkflowFragment và các trường hợp tương đương về tìm kiếm web, sau đó kiểm tra frontmatter không hợp lệ và hành vi với các engine không phải Copilot. Hoàn tất khi các bài kiểm thử được thêm bao phủ những trường hợp đã liệt kê và chạy thành công bằng lệnh kiểm thử hiện có của package.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

automated-analysis code-quality cookie enhancement report safe-outputs testing workflows
Current State
  • Test file: pkg/cli/codemod_copilot_web_fetch_test.go (316 LOC, 7 test functions, 3 t.Run)
  • Source: pkg/cli/codemod_copilot_web_fetch.go (getCopilotWebFetchRemovalCodemod, getCopilotWebSearchRemovalCodemod, applyCopilotWebToolRemoval, isNestedWorkflowFragment)
  • testify: already uses assert (21) and require (25); t.Parallel() used.
Strengths
  • Good require-for-preconditions / assert-for-values split.
  • Idempotency check (apply twice) in _Apply.
  • Covers included-engine resolution and failure-preserves-setting paths.
Prioritized improvements
1. Missing / high-value tests
  • isNestedWorkflowFragment has no direct test. Add a table test: "", .github/workflows/a.md (false), .github/workflows/shared/a.md (true), workflows/a.md (false), a/b.md without workflows (false), Windows-style separators, paths with ...
  • getCopilotWebSearchRemovalCodemod metadata (ID copilot-web-search-removal, IntroducedIn) and the web-search branch of applyCopilotWebToolRemoval are only covered in codemod_copilot_web_search_test.go; add a shared table over both codemods (tool key param) to guarantee parity.
  • Error path: Apply with malformed frontmatter / tools of non-map type should return unchanged content without error (assert explicitly).
  • Non-Copilot engine (e.g. claude) with web-fetch: true must be left unchanged.
2. Testify assertion upgrades
  • Metadata test: use assert.NotNil -> require.NotNil before invoking (already done) and add assert.Equal on Name/Description non-empty via assert.NotEmpty (present) — consider also asserting ID uniqueness against the registry (assert.Len of IDs set).
  • Use assert.Equal(t, updated, updatedAgain) -> assert.Equal is fine; prefer assert.YAMLEq only for frontmatter fragments, keep exact string equality for full-file output.
  • Add messages to key require.True(t, applied, "codemod should apply") for easier failure diagnosis.
3. Table-driven refactors

_CompatibleInputsAreUnchanged and _YAMLFormsAndLiteralText (lines ~67-220) are candidates for []struct{name, content, frontmatter, want, wantApplied} with t.Run(tt.name, ...) and t.Parallel() per subtest.

Before:

updated, applied, err := codemod.Apply(content, fm)
require.NoError(t, err)
assert.False(t, applied)

After:

for _, tt := range tests {
    t.Run(tt.name, func(t *testing.T) {
        t.Parallel()
        got, applied, err := codemod.Apply(tt.content, tt.fm)
        require.NoError(t, err)
        assert.Equal(t, tt.wantApplied, applied)
        assert.Equal(t, tt.want, got)
    })
}
4. Organization / readability
  • Extract a small helper for building engine/tools frontmatter maps to cut repeated literals.
  • Name tests by behavior (e.g. _RemovesWebFetchWithCopilotEngine).
  • Group file-resolution tests (ResolvesIncludedEngine, PreservesSettingWhenEngineResolutionFails) using shared temp-dir setup helper.

Generated by 🧪 Daily Testify Uber Super Expert · copilot · auto (powered by Gemini 3.8 Flash) · ~14 AIC · ⌖ ~1 AIC · ⊞ 9.2K · ◷

  • expires on Nov 6, 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

Mở trong Codespaces

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.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của github/gh-aw

Tất cả issue của github/gh-aw

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.