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

chore: refactor crd validation tests to deduplicate boilerplate #124

Merged
merged 2 commits into from
Oct 10, 2024

Conversation

czeslavo
Copy link
Contributor

@czeslavo czeslavo commented Oct 10, 2024

What this PR does / why we need it:

Refactors the tests under test/crdsvalidation to deduplicate the boilerplate needed for every single CRD type. This pattern of testing proved to be flexible enough to run any scenario we wanted to check, therefore I think it's worth extracting this as a common suite type.

What has been done:

  • the nested structure of tests was flattened as we no longer need isolation for the test case types named the same in every test package; now every CRD has its own single crdname_test.go file under tests/crdsvalidation
  • a generic CRDValidationTestCase was extracted along with a grouping type CRDValidationTestCasesGroup
  • all existing test cases were migrated to use the CRDValidationTestCasesGroup

What hasn't been done (aka excuses for the changes volume):

  • no new tests were added
  • no modifications to the existing test cases were done apart from:
    • renaming the <CRDName> field in the test case to TestObject
    • moving the <CRDName>Status contents from test cases that had it to the TestObject itself

Which issue this PR fixes
Enabler for #29.

@czeslavo czeslavo force-pushed the chore/dedupe-crdvalidation-tests branch from 36edba2 to 55f5be0 Compare October 10, 2024 15:45
@czeslavo czeslavo marked this pull request as ready for review October 10, 2024 15:50
@czeslavo czeslavo requested a review from a team as a code owner October 10, 2024 15:50
@czeslavo czeslavo self-assigned this Oct 10, 2024
Copy link
Member

@pmalek pmalek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🏅

Just 1 nit about the shared client.

test/crdsvalidation/suite_test.go Outdated Show resolved Hide resolved
@czeslavo czeslavo merged commit aa0209f into main Oct 10, 2024
7 checks passed
@czeslavo czeslavo deleted the chore/dedupe-crdvalidation-tests branch October 10, 2024 16:30
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.

2 participants