Skip to content

Add unit tests for sidecar set annotation parsing#147

Open
GautamBytes wants to merge 1 commit intoopenkruise:masterfrom
GautamBytes:add-sidecarset-ut
Open

Add unit tests for sidecar set annotation parsing#147
GautamBytes wants to merge 1 commit intoopenkruise:masterfrom
GautamBytes:add-sidecarset-ut

Conversation

@GautamBytes
Copy link
Copy Markdown
Contributor

This PR introduces comprehensive unit tests for the GetPodHotUpgradeInfoInAnnotations function in pkg/cmd/util/sidecar_set.go.

Reason for Change:

The GetPodHotUpgradeInfoInAnnotations function contains critical logic for parsing pod annotations, including JSON unmarshalling and handling missing data. Adding unit tests is essential to verify this logic, prevent future regressions, and improve the overall stability of the utility.

Testing Scenarios Covered:

The new test suite validates the function's behavior across multiple scenarios:

  • A pod with a valid, well-formed JSON annotation.
  • A pod that is missing the target annotation.
  • A pod with a nil or empty annotations map.
  • A pod where the annotation value contains invalid or malformed JSON.

These tests ensure the function is robust and handles both expected and edge-case inputs gracefully.

Signed-off-by: GautamBytes <manchandanigautam@gmail.com>
@kruise-bot kruise-bot requested review from FillZpp and hantmac July 12, 2025 11:07
@kruise-bot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign furykerry for approval by writing /assign @furykerry in a comment. 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

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants