Skip to content

refactor(status): move checks to operations - #561

Open
Peto-RH wants to merge 1 commit into
mainfrom
pschrimp/status-dto-options-orchestration
Open

refactor(status): move checks to operations#561
Peto-RH wants to merge 1 commit into
mainfrom
pschrimp/status-dto-options-orchestration

Conversation

@Peto-RH

@Peto-RH Peto-RH commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Move status collection behind a clean GetStatus API while keeping
dependency injection private for tests. Keep formatting, spinner, and
exit-code handling in the CLI, rendering output after collection completes.

* CardID: CCT-2407

Move status collection behind a clean GetStatus API while keeping
dependency injection private for tests. Keep formatting, spinner, and
exit-code handling in the CLI, rendering output after collection completes.
@Peto-RH
Peto-RH force-pushed the pschrimp/status-dto-options-orchestration branch from e69bfb5 to 25013e9 Compare August 24, 2026 15:37
@Peto-RH
Peto-RH marked this pull request as ready for review August 24, 2026 17:17

@zpetrace zpetrace left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mainly looking good, I am not that oriented in the code itself so my points are directed mainly towards testing but apart from few minor suggestions it looks good, thanks!:)

Comment thread cmd/rhc/status_cmd.go
Comment on lines -58 to -62
if err != nil {
systemStatus.returnCode += 1
systemStatus.ContentError = err.Error()
return fmt.Errorf("unable to check content management: %w", err)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatters are well tested, but statusAction itself isn’t (spinner, human path, JSON branch). Even a small test asserting exit code + stdout for --format json would be good IMO

Comment thread pkg/operations/status.go
Comment on lines +34 to +40
func contentIsEnabled() (bool, error) {
service, err := subman.NewRHSMClient()
if err != nil {
return false, err
}
return service.IsContentManagementEnabled()
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't contentIsEnabled open a second subman.NewRHSMClient() while registration uses IsRegistered()? Wouldn't it be better share one client per getStatus() call?

{
name: "rhsm connected",
render: func() { formatRHSMStatus(operations.StatusReport{RHSMConnected: true}) },
want: " [✓] Connected to Red Hat Subscription Management\n",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a suggestion: want strings pin literal / 𐄂 but IMO it would be better to use ui.Icons.Ok / ui.Icons.Error in expected output, or assert on message text with strings.Contains

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same goes for lines 57,72


// TestFormatStatusLines pins the exact human-readable line each formatter prints
// for its success, negative, and error states.
func TestFormatStatusLines(t *testing.T) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only format* helpers are tested here — see status_cmd.go:57 for statusAction / JSON coverage.

Comment thread pkg/operations/status.go
Comment on lines +128 to +134
if contentEnabled && report.RHSMConnected {
report.ContentEnabled = true
slog.Info("System has access to content")
} else {
report.ContentEnabled = false
slog.Info("System has no access to content")
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ContentEnabled requires contentEnabled && RHSMConnected. Content disabled alone doesn’t increment failedChecks (parity with old returnCode). Maybe worth a test like RHSM not registered + content enabled → ContentEnabled == false, failedChecks == 1?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants