Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 27, 2026

Three test files exceeded 1500 lines, causing navigation difficulties and increasing merge conflict likelihood. Split them into 10 focused files, each under 1000 lines.

Changes

pkg/cli/logs_test.go (1803→4 files)

  • logs_parsing_test.go (760 lines) - Engine-specific parsing, metric extraction, token counting
  • logs_download_test.go (537 lines) - Download orchestration, zip extraction, artifact handling
  • logs_formatting_test.go (68 lines) - Number and file size formatting
  • logs_filtering_test.go (444 lines) - Run filtering, command flags, agent log discovery

pkg/cli/mcp_server_test.go (1572→3 files)

  • mcp_server_tools_test.go (301 lines) - Tool listing, server info, capabilities
  • mcp_server_operations_test.go (347 lines) - Status, audit, context cancellation
  • mcp_server_compile_test.go (967 lines) - Compile tool variants (errors, filters, strict mode)

pkg/workflow/permissions_test.go (1551→3 files)

  • permissions_parser_test.go (707 lines) - Parser logic, access validation
  • permissions_operations_test.go (607 lines) - CRUD operations, merging
  • permissions_rendering_test.go (263 lines) - YAML rendering, AllRead handling

File naming convention

Files follow {component}_{focus_area}_test.go pattern to indicate test scope immediately.

Original prompt

This section details on the original issue you should resolve

<issue_title>[Code Quality] Refactor large test files exceeding 1500 lines for better maintainability</issue_title>
<issue_description>## Description

Several test files exceed 1500 lines, making them difficult to navigate and maintain. These should be refactored into smaller, focused test files.

Current State

Test files exceeding 1500 lines:

  • pkg/workflow/permissions_test.go (1551 lines)
  • pkg/workflow/expressions_test.go (1523 lines)
  • pkg/workflow/compiler_safe_outputs_test.go (1515 lines)
  • pkg/workflow/safe_outputs_import_test.go (1481 lines)
  • pkg/cli/logs_test.go (1803 lines)
  • pkg/cli/mcp_server_test.go (1572 lines)

Problem

  • Hard to navigate: Finding specific tests in 1500+ line files is time-consuming
  • Merge conflicts: Large files increase the likelihood of merge conflicts
  • Context switching: Developers lose context when scrolling through massive files
  • Testing complexity: Difficult to understand test coverage at a glance

Suggested Changes

Phase 1: High Priority (>1500 lines)

  1. Split pkg/cli/logs_test.go (1803 lines):

    • logs_parsing_test.go - Log parsing and analysis tests
    • logs_download_test.go - Download and file handling tests
    • logs_json_test.go - JSON output tests
    • logs_mcp_test.go - MCP-specific tests
  2. Split pkg/cli/mcp_server_test.go (1572 lines):

    • mcp_server_config_test.go - Configuration tests
    • mcp_server_validation_test.go - Validation tests
    • mcp_server_integration_test.go - Integration tests
  3. Split pkg/workflow/permissions_test.go (1551 lines):

    • permissions_validation_test.go - Permission validation tests
    • permissions_shorthand_test.go - Shorthand syntax tests
    • permissions_detailed_test.go - Detailed permission tests

Phase 2: Medium Priority (1400-1500 lines)

  1. Split remaining files following similar patterns

Naming Convention

For split test files:

  • Use descriptive suffixes that indicate the test focus area
  • Example: {original_name}_{focus_area}_test.go
  • Keep related tests together in the same file

Success Criteria

  • ✅ No test file exceeds 1000 lines
  • ✅ Test files are logically grouped by functionality
  • ✅ All tests pass (make test-unit)
  • ✅ Test coverage remains the same or improves
  • ✅ Clear naming conventions followed

Benefits

  • Improved maintainability: Easier to find and update specific tests
  • Better organization: Tests grouped by functionality
  • Reduced merge conflicts: Smaller files = fewer conflicts
  • Faster navigation: Developers can quickly locate relevant tests
  • Better test documentation: File names indicate test focus areas

Implementation Notes

  • Split tests in phases to avoid massive PRs
  • Ensure no tests are lost during refactoring
  • Run make agent-finish after each split to verify
  • Keep test helper functions in appropriate files

Source

Extracted from codebase analysis - Multiple test files exceed recommended 1000-line limit

Priority

Medium - Improves long-term maintainability but not blocking

AI generated by Discussion Task Miner - Code Quality Improvement Agent

  • expires on Feb 10, 2026, 5:12 AM UTC

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 4 commits January 27, 2026 18:13
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor large test files for better maintainability Refactor large test files (>1500 lines) into focused modules under 1000 lines Jan 27, 2026
Copilot AI requested a review from pelikhan January 27, 2026 18:27
@pelikhan pelikhan marked this pull request as ready for review January 27, 2026 18:27
@pelikhan pelikhan merged commit c689053 into main Jan 27, 2026
56 checks passed
@pelikhan pelikhan deleted the copilot/refactor-large-test-files branch January 27, 2026 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Code Quality] Refactor large test files exceeding 1500 lines for better maintainability

2 participants