Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webhook integration tests and clean up MatchCondition validation code #957

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

jvanz
Copy link
Member

@jvanz jvanz commented Jan 10, 2025

Description

Adds tests to ensure that the function used by the webhooks server is calling the correct validation functions and moves the code from policy_validation_matchconditions.go file into policy_validation.go file, removing the unnecessary code.

Fix #824

Test

make test 

@jvanz jvanz self-assigned this Jan 10, 2025
Copy link

codecov bot commented Jan 10, 2025

Codecov Report

Attention: Patch coverage is 95.73935% with 17 lines in your changes missing coverage. Please review.

Project coverage is 71.10%. Comparing base (73de594) to head (e2cbf44).

Files with missing lines Patch % Lines
api/policies/v1/policy_validation.go 70.17% 11 Missing and 6 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #957      +/-   ##
==========================================
+ Coverage   67.35%   71.10%   +3.74%     
==========================================
  Files          30       30              
  Lines        3128     3440     +312     
==========================================
+ Hits         2107     2446     +339     
+ Misses        852      836      -16     
+ Partials      169      158      -11     
Flag Coverage Δ
integration-tests 60.61% <76.69%> (+4.02%) ⬆️
unit-tests 51.28% <78.44%> (+10.86%) ⬆️

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.

@jvanz
Copy link
Member Author

jvanz commented Jan 10, 2025

@fabriziosestito this is not exactly what I want to show you because I still have the new tests under the controller directory. But I could not finish the changes yet. Therefore, I'll leave it as it is now and continue next day.

@jvanz jvanz added the area/qa label Jan 10, 2025
@jvanz jvanz force-pushed the enable-webhooks branch 4 times, most recently from a40e45c to e234cf3 Compare January 10, 2025 19:32
Move the factories used in tests to build our types to the policies/v1
package. Therefore, all the tests under /api and /internal/controller
directories can use them.

Signed-off-by: José Guilherme Vanz <jguilhermevanz@suse.com>
@jvanz jvanz marked this pull request as ready for review January 10, 2025 20:22
@jvanz jvanz requested a review from a team as a code owner January 10, 2025 20:22
@jvanz jvanz changed the title feat(test): enable webhook server for the envtests. feat(test): integration test for webhook. Jan 10, 2025
Adds tests to ensure that the function used by the webhooks server is
calling the correct validation functions.

Signed-off-by: José Guilherme Vanz <jguilhermevanz@suse.com>
@jvanz jvanz changed the title feat(test): integration test for webhook. feat(tests): webhook integration tests. Jan 10, 2025
Moves the code from policy_validation_matchconditions.go file into
policy_validation.go file, removing the unnecessary code.

Signed-off-by: José Guilherme Vanz <jguilhermevanz@suse.com>
@jvanz jvanz changed the title feat(tests): webhook integration tests. Webhook integration tests and clean up MatchCondition validation code Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor policy validation on create and update, including tests
1 participant