Skip to content

Add unit tests for attachablePodForObject function#139

Open
GautamBytes wants to merge 1 commit intoopenkruise:masterfrom
GautamBytes:test/add-attachable-pod-test
Open

Add unit tests for attachablePodForObject function#139
GautamBytes wants to merge 1 commit intoopenkruise:masterfrom
GautamBytes:test/add-attachable-pod-test

Conversation

@GautamBytes
Copy link
Copy Markdown
Contributor

@GautamBytes GautamBytes commented Jul 10, 2025

Added unit test for pkg/internal/polymorphichelpers/attachablepodforobject.go .

Our tests successfully validated all the logic paths that don't require a live Kubernetes connection:

  • The case where the object is already a pod.
  • The error path if the REST config fails.
  • The error path if SelectorsForObject fails (e.g., for an unsupported type).

The uncovered code is the final "success path" where the function tries to:

  • Create a real Kubernetes clientset.
  • Use that clientset to find and retrieve a running pod.

This part of the code is not covered because a simple unit test cannot create a real Kubernetes client and connect to the API.

Signed-off-by: GautamBytes <manchandanigautam@gmail.com>
@kruise-bot kruise-bot requested review from FillZpp and furykerry July 10, 2025 11:54
@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 hantmac for approval by writing /assign @hantmac 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

@GautamBytes
Copy link
Copy Markdown
Contributor Author

@furykerry @FillZpp just pinging for review. Thanks!

@GautamBytes
Copy link
Copy Markdown
Contributor Author

@furykerry @FillZpp just pinging for review. Thanks!

@furykerry PTAL!

@GautamBytes
Copy link
Copy Markdown
Contributor Author

@furykerry @hantmac will you merge these test pr's please!

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