[oadp-1.5] OADP-8508: Fix schedule create examples showing velero instead of oc oadp - #246
Conversation
|
@openshift-cherrypick-robot: Ignoring requests to cherry-pick non-bug issues: OADP-8508 DetailsIn response to this:
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. |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
| 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) | ||
| } | ||
| } |
There was a problem hiding this comment.
And you change this to assert equals (as well) so that we can see the exact replaced statement.
There was a problem hiding this comment.
🧩 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 usinggo build. Applies a build timeout and fails the test with build output if compilation fails. Used bycmd/root_test.goroot-command and namespace tests. -
Lines 97–122 —
RunCommand
Executes the built binary with the supplied arguments underTestTimeout, captures stdout and stderr, logs command/output details, and returns stdout plus the execution error. -
Lines 125–140 —
TestHelpCommand
Runs a CLI help command viaRunCommand, 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 byRunCommandand related command execution tests.
You are interacting with an AI system.
|
[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 DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/lgtm |
This is an automated cherry-pick of #243
/assign NicholasYancey