fix: fixing some misleading unit test case names #4934
Merged
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.
What type of PR is this?
Fix
What this PR does / why we need it:
Some of the test cases in
api/v1alpha1/validation/envoyproxy_validate_test.go
were misleading.I initially noticed a couple test cases were named "invalid" but they were actually valid scenarios, and were being checked as such with the
expected: true
field in the test table. This was for e.g.should be invalid when service patch type is empty
Upon this, also realized there two tests were not testing what they were supposed to be. E.g.
should be invalid when pdb type not set
should be valid, and was only invalid because the test did have the patch type set and did not the patch object, causing the invalid result. The correct thing to test for would be a valid case wheretype
is not set, butpatch
is.Also added more specific test names for the deployment cases, since we test patches for all
deployment,daemonset,service,hpa,pdb
in the validation tests, as well as fixed a misleading comment/log message inkubernetes_helpers.go
that was related to similar codepaths.Which issue(s) this PR fixes:
Fixes #4933
Release Notes: No