Skip to content

test(util): cover MarkAnnotationsToDelete - #2980

Closed
magic-peach wants to merge 1 commit into
Project-HAMi:masterfrom
magic-peach:test-mark-annotations-to-delete
Closed

test(util): cover MarkAnnotationsToDelete#2980
magic-peach wants to merge 1 commit into
Project-HAMi:masterfrom
magic-peach:test-mark-annotations-to-delete

Conversation

@magic-peach

@magic-peach magic-peach commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

What type of PR is this?
/kind cleanup

What this PR does / why we need it:
util.MarkAnnotationsToDelete is the only exported function in pkg/util/util.go without a direct unit test. It's a thin wrapper over GetNode and RemoveNodeAnnotation, both already tested individually, but its own composition and error-propagation path (when GetNode fails) were untested. Adds TestMarkAnnotationsToDelete and TestMarkAnnotationsToDelete_NodeNotFound following the existing fake-clientset pattern used by the neighboring GetNode/RemoveNodeAnnotation tests.

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:
Test-only change, no production code touched. Ran go test ./pkg/util/... -run TestMarkAnnotationsToDelete -v --race -count=1, both new tests pass.

Does this PR introduce a user-facing change?:
NONE


This PR was written primarily by Claude Code, an AI assistant, under my direction and review. I verified the tests by running them locally and reviewed the diff before submitting.

Summary by CodeRabbit

  • Tests
    • Added coverage for successfully removing node annotations.
    • Added coverage for handling cases where the specified annotation is not found.

It wraps GetNode and RemoveNodeAnnotation, both already tested, but
its own composition and the node-not-found error path had no direct
test. Add one covering the success path and that path.

Signed-off-by: Akanksha Trehun <akankshatrehun@gmail.com>
@hami-robot

hami-robot Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: magic-peach
Once this PR has been reviewed and has the lgtm label, please assign wawa0210 for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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

@coderabbitai

coderabbitai Bot commented Sep 7, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: bd91ab96-b2dd-4195-a220-554915afb89f

📥 Commits

Reviewing files that changed from the base of the PR and between 1092ba2 and d6ad833.

📒 Files selected for processing (1)
  • pkg/util/util_test.go

Included review availability: Your plan provides up to 8 included reviews per hour; 6 remain after this review.


📝 Walkthrough

Walkthrough

The change adds tests for MarkAnnotationsToDelete. The tests cover annotation removal from an existing node and the not-found error for a missing node.

Changes

Annotation deletion test coverage

Layer / File(s) Summary
MarkAnnotationsToDelete behavior validation
pkg/util/util_test.go
Adds tests for removing a specified annotation and returning a not-found error when the node is missing.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Merge Risk: 🔵 Low · up to d6ad8

This test-only change adds coverage for annotation removal and missing-node handling without changing runtime behavior. The missing-node test could accept a different error with similar text, so the coverage is slightly less durable but remains mergeable.

Poem

A rabbit checks the node with care
An annotation vanishes from there
A missing node says, “Not found”
The tests record the result sound
Green checks hop across the ground

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding tests for MarkAnnotationsToDelete.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@Eshiv-Pandey

Copy link
Copy Markdown
Contributor

Thanks! But MarkAnnotationsToDelete isn't actually untested... TestRemoveAnnotation (from #2052) already covers both the success and GetNode-not-found paths.

@magic-peach

Copy link
Copy Markdown
Contributor Author

You're right, thanks for catching that. TestRemoveAnnotation from #2052 already covers both branches through MarkAnnotationsToDelete directly, I missed it because the test function isn't named after the function it exercises. Closing this, no new coverage here.

@magic-peach magic-peach closed this Sep 8, 2026
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