karmada/pkg/webhook/federatedhpa
Mohamed Awnallah e5169f8889 pkg/webhook: test FederatedHPA
In this commit, we introduce unit tests for both the `MutatingAdmission`
and `ValidatingAdmission` webhooks specifically for the `FederatedHPA`
resource.

The tests include:

- Validation webhook tests:
  - Verifies that admission is denied with an appropriate error message
    when decoding the request object fails.
  - Ensures admission is denied when the `FederatedHPA` spec contains
    invalid values, such as a `minReplicas` set to zero, and the correct
    error message is returned.
  - Confirms that a valid `FederatedHPA` object is allowed through without
    errors.

- Mutation webhook tests:
  - Verifies that admission is denied when decoding the request object
    fails, returning the appropriate error message.
  - Ensures that the `FederatedHPA` object is correctly mutated when
    provided with default values, including scale policies and CPU
    utilization.
  - Confirms that no patches are applied when the `FederatedHPA` object is
    handled correctly and that admission is allowed for valid
    `FederatedHPA` objects.

Signed-off-by: Mohamed Awnallah <mohamedmohey2352@gmail.com>
2024-09-09 15:51:02 +03:00
..
mutating.go Adopt controller-runtime braking changes: generics support PR2783 2024-07-13 16:49:01 +08:00
mutating_test.go pkg/webhook: test FederatedHPA 2024-09-09 15:51:02 +03:00
validating.go Adopt controller-runtime braking changes: generics support PR2783 2024-07-13 16:49:01 +08:00
validating_test.go pkg/webhook: test FederatedHPA 2024-09-09 15:51:02 +03:00