Skip to content

Standardize test seams for ROSA CLI commands #3383

Description

@coderabbitai

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

  1. Agree on the preferred command test-seam pattern for dependencies outside *rosa.Runtime.
  2. Refactor cmd/initialize to the agreed pattern, if appropriate.
  3. Apply the agreed pattern to comparable command packages where doing so improves consistency.
  4. 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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions