Skip to content

APT CommandRunner Migration (Issue #20 Part 1) #27

@bluet

Description

@bluet

Summary

Complete APT package manager migration from CommandBuilder to CommandRunner interface, achieving unified testable command execution architecture.

This is Part 1 of Issue #20 - CommandRunner Pattern Implementation

Scope

  • APT package manager only - Complete CommandRunner migration
  • Constructor standardization - Clear production vs testing patterns
  • Utility function refactoring - Convert functions to methods for better encapsulation
  • Legacy cleanup - Remove CommandBuilder files
  • Documentation updates - Reflect new architecture

Technical Implementation

APT CommandRunner Migration

  • Replace all exec.Command calls with CommandRunner interface
  • Automatic LC_ALL=C handling for consistent English output
  • Built-in interactive mode support via RunInteractive()
  • Dependency injection for comprehensive testing

Constructor Standardization

  • NewPackageManager() - Production use with default CommandRunner
  • NewPackageManagerWithCustomRunner() - Testing use with mock CommandRunner
  • Clear naming convention eliminates confusion

Encapsulation Improvements

Convert utility functions to methods:

  • ParseFindOutput(msg, opts, runner)(a *PackageManager) ParseFindOutput(msg, opts)
  • getPackageStatus(packages, opts, runner)(a *PackageManager) getPackageStatus(packages, opts)
  • runDpkgQuery(packageNames, opts, runner)(a *PackageManager) runDpkgQuery(packageNames, opts)

Benefits: Eliminates parameter explosion through 3-4 function levels, better encapsulation using a.getRunner() directly

Acceptance Criteria

  • APT migrated from CommandBuilder to CommandRunner
  • Constructor naming standardized across APT and YUM
  • Utility functions converted to methods for better encapsulation
  • CommandBuilder legacy files removed
  • Comprehensive test coverage maintained
  • LC_ALL=C automatically handled
  • Interactive mode works consistently
  • All existing functionality preserved
  • Documentation updated

Implementation Status

COMPLETED by PR #26

Related Issues

Testing

  • All existing APT tests pass
  • New CommandRunner mock tests added
  • Cross-platform testing verified
  • Environment variable handling tested
  • Interactive mode validation completed

Priority

High Priority - Core architectural improvement that enables consistent testing patterns and better code organization.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions