-
Notifications
You must be signed in to change notification settings - Fork 7
Closed
Description
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.Commandcalls 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 CommandRunnerNewPackageManagerWithCustomRunner()- 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
- Part of Issue Implement CommandRunner pattern for unified testable package manager operations #20 - CommandRunner Pattern Implementation
- Followed by Issue Implement CommandRunner pattern for unified testable package manager operations #20-2 (Snap) and Issue Implement CommandRunner pattern for unified testable package manager operations #20-3 (Flatpak)
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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels