Skip to content

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

@github-actions

Description

@github-actions

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

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions