[SREP-1063] chore: move console container logic to a dedicated module to improve test by feichashao · Pull Request #725 · openshift/backplane-cli
What type of PR is this?
- Bug
- Feature
- Documentation
- Test Coverage
- Clean Up
- Others
What this PR does / Why we need it?
This PR moves the container engine related logic to a dedicated package container.
Although those container-dependent implementation are for serving console, it could improve test-ability by separating it from the console package. The console package can focus on the container-engine independent logic, while the container package handles the Linux/Mac + Podman/Docker specific logic.
By doing so, we can mock the ContainerEngine interface and use it for testing.
This PR doesn't change console behavior, nor add any new feature. After merging this PR, I will add test for SREP-1063.
Which Jira/Github issue(s) does this PR fix?
Related to SREP-1063
Special notes for your reviewer
Main changes:
- Move the ContainerEngine interface and implementation to module
container. - Use a factory function
NewEngineto provide different implementation based on the OS/Engine. - Mocked ContainerEngine
- Adjust the unit test where it needs an ContainerEngine to use the mocked one.
Unit Test Coverage
Guidelines
- If it's a new sub-command or new function to an existing sub-command, please cover at least 50% of the code
- If it's a bug fix for an existing sub-command, please cover 70% of the code
Test coverage checks
- Added unit tests
- Created jira card to add unit test
- This PR may not need unit tests
Pre-checks (if applicable)
- Ran unit tests locally
- Validated the changes in a cluster
- Included documentation changes with PR