Skip to content

Add unit tests for historyViewer #142

Open
GautamBytes wants to merge 1 commit intoopenkruise:masterfrom
GautamBytes:add-historyviewer-unit-tests
Open

Add unit tests for historyViewer #142
GautamBytes wants to merge 1 commit intoopenkruise:masterfrom
GautamBytes:add-historyviewer-unit-tests

Conversation

@GautamBytes
Copy link
Copy Markdown
Contributor

This PR introduces two small indirection hooks in historyviewer.go - coreNewForConfig and kruiseNewForConfig - that default to the real Kubernetes and Kruise client constructors. By doing so we can inject failures in unit tests without altering any production behavior.

Additionally, it adds a new test file historyviewer_test.go which achieves 100% coverage of the historyViewer function’s error paths:

  • RESTConfig failure: ensures an error from ToRESTConfig is propagated unchanged.
  • Kubernetes client construction failure: simulates NewForConfig returning an error (“core fail”).
  • Kruise client construction failure: simulates NewForConfig returning an error (“kruise fail”).

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