Skip to content

Conversation

@GautamBytes
Copy link
Contributor

What this PR does / Why we need it
The pkg/webhook/server.go file contains the core logic for registering and managing webhook handlers. This PR introduces unit tests to validate this logic, ensure its correctness, and prevent future regressions.

Scope of Testing
These tests focus on the pure, stateless logic functions within the file:

  • addHandlers() and addHandlersWithGate() are tested to ensure they correctly add handlers, normalize paths, and handle gates.
  • filterActiveHandlers() is tested to verify that inactive handlers are correctly removed from the map based on their gate functions.

The integration functions (SetupWithManager, initialize), which are responsible for wiring together controller-runtime components and involve concurrency, have been intentionally excluded from this unit test suite. They are better suited for future integration tests.

@kruise-bot kruise-bot requested review from furykerry and veophi July 14, 2025 18:07
@kruise-bot
Copy link

[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 zmberg for approval by writing /assign @zmberg 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.

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

Signed-off-by: GautamBytes <[email protected]>
@GautamBytes GautamBytes force-pushed the add-webhook-server-tests branch from 7717d8c to 54b6bc3 Compare August 13, 2025 18:29
Signed-off-by: GautamBytes <[email protected]>
@codecov
Copy link

codecov bot commented Aug 14, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 47.81%. Comparing base (00aae12) to head (797bdf8).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #294      +/-   ##
==========================================
+ Coverage   47.52%   47.81%   +0.28%     
==========================================
  Files          63       66       +3     
  Lines        9799     9864      +65     
==========================================
+ Hits         4657     4716      +59     
- Misses       4585     4589       +4     
- Partials      557      559       +2     
Flag Coverage Δ
unittests 47.81% <100.00%> (+0.28%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Signed-off-by: GautamBytes <[email protected]>
@kruise-bot kruise-bot added size/L and removed size/M labels Aug 15, 2025
Signed-off-by: GautamBytes <[email protected]>
Signed-off-by: GautamBytes <[email protected]>
@GautamBytes
Copy link
Contributor Author

@veophi can u help me with this linter failing workflow , i am running it locally but it still fails somehow , never happened for other prs!

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