Skip to content

Flatpak CommandRunner Migration (Issue #20 Part 3) #29

@bluet

Description

@bluet

Summary

Migrate Flatpak package manager from direct exec.Command calls to unified CommandRunner interface for consistent, testable command execution architecture.

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

Background

Complete the CommandRunner migration initiative by implementing unified command execution patterns for Flatpak, achieving full architectural consistency across all package managers.

Current State

Scope

  • Flatpak package manager migration from exec.Command to CommandRunner
  • Constructor standardization following established APT/YUM/Snap patterns
  • Dependency injection for comprehensive testing capabilities
  • Test coverage expansion (currently 0% coverage for Flatpak)

Technical Implementation

CommandRunner Integration

  • Replace all exec.Command calls with CommandRunner interface
  • Implement automatic LC_ALL=C handling for consistent English output
  • Add built-in interactive mode support via RunInteractive()
  • Enable dependency injection for testing

Constructor Pattern

Following established standardization:

  • NewPackageManager() - Production use with default CommandRunner
  • NewPackageManagerWithCustomRunner() - Testing use with mock CommandRunner

Testing Infrastructure

  • Implement comprehensive mock-based testing
  • Add environment variable tracking capabilities
  • Create cross-platform test scenarios
  • Achieve significant test coverage improvement (currently 0%)

Benefits

Architecture Benefits

  • Complete consistency - All package managers use same CommandRunner pattern
  • Automatic LC_ALL=C - No manual environment setup needed
  • Built-in interactive support - Proper stdin/stdout/stderr handling
  • Unified codebase - Same patterns and interfaces everywhere

Testing Benefits

  • Consistent testing - Same mocking approach across all package managers
  • Environment testing - Built-in environment variable verification
  • Cross-platform testing - Same tests work across all environments
  • Full coverage - All command execution paths testable

Project Completion

Acceptance Criteria

  • Flatpak migrated from direct exec.Command to CommandRunner
  • Constructor naming follows established patterns
  • Dependency injection implemented for testing
  • Comprehensive test coverage added (target: >80%)
  • LC_ALL=C automatically handled
  • Interactive mode works consistently
  • All existing functionality preserved
  • Documentation updated
  • Issue Implement CommandRunner pattern for unified testable package manager operations #20 marked as complete

Priority

Medium Priority - Final piece of architectural consistency improvement.

Dependencies

Related Issues

Implementation Notes

  • Follow proven patterns from APT migration (Issue APT CommandRunner Migration (Issue #20 Part 1) #27)
  • Leverage existing CommandRunner interface and MockCommandRunner
  • Maintain backward compatibility during migration
  • Use established testing frameworks and patterns
  • This completes the full CommandRunner migration across all package managers

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