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

validation: establish a pattern for metatests #687

Merged
merged 3 commits into from
Nov 18, 2024

Conversation

geoknee
Copy link
Collaborator

@geoknee geoknee commented Nov 15, 2024

This diff is actually very small, it only seems big because of a rename.

The philosophy here is to place test helper code in files which do not have _test.go suffix. Only the top level entry file needs to have that suffix (validation_test.go). This frees up the associated _test.go file to hold metatests: namely tests which try to ensure the test code itself is bug free.

I added one such new metatest which exposes a bug in our version checking code. You can see this by the failing CI check.

This PR also includes the fix to make that test pass.

Towards #686

@geoknee geoknee requested a review from a team as a code owner November 15, 2024 12:27
@geoknee geoknee changed the title validatoin: establish a pattern for metatests validation: establish a pattern for metatests Nov 15, 2024
@geoknee geoknee force-pushed the gk/validation-contract-version-bug2 branch from e5b0c96 to e2d97ae Compare November 15, 2024 12:33
@geoknee
Copy link
Collaborator Author

geoknee commented Nov 18, 2024

The idea would be to have the majority of the complexity of our validation tests refactored into functions which are:

  • pure
  • do not take a testing.T (are not tightly coupled to a testing framework)
  • do not do any data scraping, but accept the "on chain data" as input
  • return useful information about whether the input data passes validation

This way, we can easily:

  • inject test data locally
  • reuse the pure functions in other applications easily.
  • write "meta tests" (we wouldn't even need to call them that) easily without having to mock testing.T.

@geoknee geoknee added this pull request to the merge queue Nov 18, 2024
Merged via the queue into main with commit e7e6fc8 Nov 18, 2024
11 checks passed
@geoknee geoknee deleted the gk/validation-contract-version-bug2 branch November 18, 2024 21:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants