Add unit tests for pod create/update handler #2101
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Ⅰ. Describe what this PR does
This pull request introduces a unit test suite for the pod validating webhook handler located in pkg/webhook/pod/validating/pod_create_update_handler.go.
The primary goal is to increase test coverage and ensure the reliability of the webhook's core dispatch logic. The tests use a mock handler to verify that admission requests are correctly routed to either the WorkloadSpread or PodUnavailableBudget validation functions based on the operation type (CREATE, UPDATE, DELETE) and the state of their respective feature gates.
Ⅱ. Does this pull request fix one issue?
in support of #2074
Ⅲ. Describe how to verify it
You can verify this PR by running the tests for the specific package and ensuring they pass:
go test ./pkg/webhook/pod/validating -v
All newly added tests for pod_create_update_handler should pass successfully.