ROSAENG-60112 | test: add tests for delete cluster command#3298
Conversation
|
Skipping CI for Draft Pull Request. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Central YAML (inherited) Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughA Ginkgo/Gomega test suite was added for 🚥 Pre-merge checks | ✅ 13 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (13 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
You can safely override the ci/prow/security for now. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@cmd/dlt/cluster/cmd_test.go`:
- Around line 78-96: The test in handleClusterDelete only covers the success
path and does not verify that the delete request carries bestEffort through.
Update the cmd/dlt/cluster/cmd_test.go spec around handleClusterDelete to
inspect the outgoing delete call from the ApiServer mock and assert it includes
best_effort=true, using the existing clusterReady, clusterId, and bestEffort
flow so the test validates the pass-through contract rather than just a happy
path.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Central YAML (inherited)
Review profile: CHILL
Plan: Enterprise
Run ID: b7a566a4-60ab-4f76-a3df-8841130e5cbf
📒 Files selected for processing (2)
cmd/dlt/cluster/cluster_suite_test.gocmd/dlt/cluster/cmd_test.go
efd5acf to
a2de374
Compare
Add focused tests for the delete cluster command's core logic: - handleClusterDelete: cluster already uninstalling, happy path deletion, bestEffort flag passthrough, GetClusterState API error, DeleteCluster API error - buildCommands: non-reusable OIDC config uses cluster ID flags, reusable OIDC config uses prefix and oidc-config-id flags
a2de374 to
5faaf6c
Compare
|
/override ci/prow/security |
|
@olucasfreitas: Overrode contexts on behalf of olucasfreitas: ci/prow/security 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 kubernetes-sigs/prow repository. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3298 +/- ##
==========================================
+ Coverage 27.02% 27.14% +0.11%
==========================================
Files 334 334
Lines 36704 36704
==========================================
+ Hits 9920 9964 +44
+ Misses 26029 25985 -44
Partials 755 755 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
/approve |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: amandahla, olucasfreitas 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 |
0e83a7c
into
openshift:master
PR Summary
Add focused unit tests for the delete cluster command at
cmd/dlt/cluster/, covering the core business logic inhandleClusterDeleteand the cleanup command builderbuildCommands.Detailed Description of the Issue
The delete cluster command had 0% test coverage. This is one of the most critical user-facing workflows in the ROSA CLI. The command handles cluster state validation, deletion via the OCM API, and generating cleanup instructions for STS resources (operator roles and OIDC providers).
This PR tests the two internal functions that contain the actual decision logic, without needing to trap
os.Exitfrom the legacyRun: runCobra pattern.Related Issues and PRs
Type of Change
Previous Behavior
cmd/dlt/cluster/had no automated test coverage.Behavior After This Change
Six focused test cases covering:
handleClusterDelete(4 tests):DeleteClustersucceeds, returns nilGetClusterStateAPI error: propagatedDeleteClusterAPI error: propagatedbuildCommands(2 tests):-c <clusterID>--prefixand--oidc-config-idHow to Test (Step-by-Step)
Preconditions
Test Steps
go test ./cmd/dlt/cluster/... -count=1 -vgo vet ./cmd/dlt/cluster/...Expected Results
go vetcleanProof of the Fix
Breaking Changes
Developer Verification Checklist
[JIRA-TICKET] | [TYPE]: <MESSAGE>.make install-hookshas been run in this clone.make testpasses.make lintpasses.make rosapasses.Summary by CodeRabbit