Open
Conversation
Extract duplicated management policy validation tests from all 22 resource test files into a generic runManagementPolicyTests helper in common_test.go. This reduces ~100 lines of duplicated test code per file to ~13 lines of resource-specific callbacks. The shared helper covers all standard management policy validations: - Default management policy is managed - Require import for unmanaged - Not permit unmanaged with resource - Not permit empty import - Not permit empty import filter - Permit valid import filter - Require resource for managed - Not permit managed with import - Not permit managedOptions for unmanaged - Permit managedOptions for managed For network, port, and subnet, this also adds previously missing management policy test coverage. Disable the dupl linter for test/ since the remaining per-resource callback boilerplate is inherently similar.
Add a template that generates test/apivalidations/<resource>_test.go when scaffolding a new controller. The generated test file includes management policy tests via the shared runManagementPolicyTests helper, required field validation, and immutability tests for all dependency refs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This add tests for all existing resources.
Assisted-By: claude-opus-4-6