Skip to content

[oadp-1.5] OADP-8508: Fix schedule create examples showing velero instead of oc oadp - #246

Merged
openshift-merge-bot[bot] merged 1 commit into
migtools:oadp-1.5from
openshift-cherrypick-robot:cherry-pick-243-to-oadp-1.5
Jul 31, 2026
Merged

[oadp-1.5] OADP-8508: Fix schedule create examples showing velero instead of oc oadp#246
openshift-merge-bot[bot] merged 1 commit into
migtools:oadp-1.5from
openshift-cherrypick-robot:cherry-pick-243-to-oadp-1.5

Conversation

@openshift-cherrypick-robot

Copy link
Copy Markdown

This is an automated cherry-pick of #243

/assign NicholasYancey

@openshift-ci-robot

openshift-ci-robot commented Jul 31, 2026

Copy link
Copy Markdown

@openshift-cherrypick-robot: Ignoring requests to cherry-pick non-bug issues: OADP-8508

Details

In response to this:

This is an automated cherry-pick of #243

/assign NicholasYancey

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 06f8a813-24cc-40df-ac44-dc7a42527ef5

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@openshift-ci
openshift-ci Bot requested review from kaovilai and weshayutin July 31, 2026 14:07
Comment thread cmd/root_test.go
Comment on lines +228 to +250
func TestReplaceVeleroWithOADP_ScheduleCreateVerbFirst(t *testing.T) {
cmd := &cobra.Command{
Use: "test",
Example: ` # Create a backup every 6 hours.
velero create schedule NAME --schedule="0 */6 * * *"

# Create a backup every 6 hours with the @every notation.
velero create schedule NAME --schedule="@every 6h"`,
}

replaceVeleroWithOADP(cmd)

if strings.Contains(cmd.Example, "velero create schedule") {
t.Errorf("Expected verb-first 'velero create schedule' to be normalized, got: %s", cmd.Example)
}
if strings.Contains(cmd.Example, "velero") {
t.Errorf("Expected 'velero' to be fully replaced, got: %s", cmd.Example)
}
wantCount := strings.Count(cmd.Example, "oc oadp schedule create NAME")
if wantCount != 2 {
t.Errorf("Expected 2 occurrences of 'oc oadp schedule create NAME', got %d\nActual output:\n%s", wantCount, cmd.Example)
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

And you change this to assert equals (as well) so that we can see the exact replaced statement.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

maybe followup..

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@coderabbitai create issue.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo="migtools/oadp-cli"
title="Add exact-output assertion for schedule create example normalization"
body=$(cat <<'EOF'
## Summary

Add an exact-output assertion to `TestReplaceVeleroWithOADP_ScheduleCreateVerbFirst` in `cmd/root_test.go`.

## Required change

Keep the existing checks for the removal of `velero create schedule` and the occurrence count. Also compare `cmd.Example` with the complete expected normalized example string. The failure output must show the expected and actual strings.

## Rationale

The occurrence-count check verifies only part of the replacement. An exact-output assertion verifies the complete transformed command text, including both `velero create schedule NAME` replacements and the surrounding content.

## Affected area

- `cmd/root_test.go`
- `TestReplaceVeleroWithOADP_ScheduleCreateVerbFirst`

## Acceptance criteria

- The test declares the complete expected normalized example text.
- The test compares `cmd.Example` to that expected text.
- A test failure reports both the expected and actual values.
- Existing relevant assertions remain valid or are replaced by the exact-output assertion where redundant.

## Backlinks

- Pull request: https://github.com/migtools/oadp-cli/pull/246
- Review comment: https://github.com/migtools/oadp-cli/pull/246#discussion_r3691788318
- Requested by: `@kaovilai`
EOF
)

gh issue create \
  --repo "$repo" \
  --title "$title" \
  --body "$body" \
  --assignee "kaovilai"

Length of output: 2571


@kaovilai, I created and assigned #252: Add exact-output assertion for schedule create example normalization.


🧬 Code Graph Analysis Results

internal/testutil/testutil.go

  • Lines 65–94 — BuildCLIBinary
    Builds the CLI binary from the project root into a temporary directory using go build. Applies a build timeout and fails the test with build output if compilation fails. Used by cmd/root_test.go root-command and namespace tests.

  • Lines 97–122 — RunCommand
    Executes the built binary with the supplied arguments under TestTimeout, captures stdout and stderr, logs command/output details, and returns stdout plus the execution error.

  • Lines 125–140 — TestHelpCommand
    Runs a CLI help command via RunCommand, logs its output, and reports an error for each expected string absent from stdout. Non-zero command exit status is tolerated.

  • Line 34 — TestTimeout
    Defines the 30-second timeout used by RunCommand and related command execution tests.

You are interacting with an AI system.

@openshift-ci

openshift-ci Bot commented Jul 31, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kaovilai, openshift-cherrypick-robot, sseago

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sseago

sseago commented Jul 31, 2026

Copy link
Copy Markdown

/lgtm

@openshift-ci openshift-ci Bot added the lgtm label Jul 31, 2026
@openshift-merge-bot
openshift-merge-bot Bot merged commit f2cb269 into migtools:oadp-1.5 Jul 31, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants