Summary
Standardize the testability pattern used by ROSA CLI command packages under cmd/ so future coverage work does not introduce multiple dependency-injection conventions.
cmd/initialize/cmd.go currently uses an explicit initDeps / defaultInitDeps() dependency bundle. Other commands generally use runWithRuntime(*rosa.Runtime) with runtime mocks, or package-level function-variable seams (for example, cmd/download/oc) that tests temporarily override and restore.
This follow-up is intentionally separate from the test-coverage work in #3368.
Rationale
A single, documented convention will reduce cognitive overhead and make command implementations and tests easier to maintain consistently.
Affected areas
cmd/initialize/cmd.go
- Existing command packages that need seams not represented by
*rosa.Runtime
- Command testing guidance and examples, as appropriate
Required changes
- Agree on the preferred command test-seam pattern for dependencies outside
*rosa.Runtime.
- Refactor
cmd/initialize to the agreed pattern, if appropriate.
- Apply the agreed pattern to comparable command packages where doing so improves consistency.
- Ensure tests that override package-level variables restore their original values to prevent cross-test interference.
Acceptance criteria
- A documented and consistently applied convention exists for command-level test seams.
cmd/initialize follows that convention or has a documented exception.
- Relevant tests remain deterministic and do not leak modified global state.
- Targeted tests and the repository's standard Go verification commands pass.
Context
Requested by @amandahla.
Summary
Standardize the testability pattern used by ROSA CLI command packages under
cmd/so future coverage work does not introduce multiple dependency-injection conventions.cmd/initialize/cmd.gocurrently uses an explicitinitDeps/defaultInitDeps()dependency bundle. Other commands generally userunWithRuntime(*rosa.Runtime)with runtime mocks, or package-level function-variable seams (for example,cmd/download/oc) that tests temporarily override and restore.This follow-up is intentionally separate from the test-coverage work in #3368.
Rationale
A single, documented convention will reduce cognitive overhead and make command implementations and tests easier to maintain consistently.
Affected areas
cmd/initialize/cmd.go*rosa.RuntimeRequired changes
*rosa.Runtime.cmd/initializeto the agreed pattern, if appropriate.Acceptance criteria
cmd/initializefollows that convention or has a documented exception.Context
Requested by @amandahla.