test: improve namespace webhook tests #123
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.
While working on #121 I noticed some flaky tests I have seen before in previous pull requests. Flakes are annoying, so this PR attempts to improve this somehow.
Since the webhook uses a caching client, the webhook might deny the request based on a non-updated cache. If the test creates a namespace referring to another namespace just created, this can make the test fail. Hopefully, this PR will improve the situation by replacing
Except
withEventually
in such cases.I have also added assertions of error messages expected from the webhook for denied requests. This should prevent tests from passing if the request fails for any other reason than the expected. This will force us to update the test if error messages are changed, but I think this makes sense.