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

Add property-based testing for query filtering #64

Open
gregbrowndev opened this issue Sep 13, 2023 · 0 comments
Open

Add property-based testing for query filtering #64

gregbrowndev opened this issue Sep 13, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@gregbrowndev
Copy link
Owner

gregbrowndev commented Sep 13, 2023

The find all jobs API, GET /api/jobs, takes a set of 7 filters. The core jobs service unit test and e2e test needs more coverage of this functionality. We need to use property-based testing to try all the possibilities. We need to generate a large enough dataset and write an interpreter to persist this data into the application. Fortunately, the data model is simple, as there is only a single Job table with no foreign keys. This means we can generate a list of jobs without managing dependencies with other jobs.

Because the core JobService handles the find query, unit testing this with property-based testing has little value as we'd just be testing the fake in-memory implementation. To test the query logic, we'd have to property-based test the e2e test of the REST API. Now is a good time to iterate on the architecture and refactor queries into a separate QueryService that does direct SQL queries to the DB. This will remove the wasted effort of duplicating and testing the query logic on the fake repository. This issue is tracked here: #65.

For now, however, just property-based test the LiveJobRepository and keep the JobService unit test and JobRoutes e2e test lightweight. This is much simpler as the integration test can cleanly roll back the transaction after each test.

Requirements:

  • Add property-based testing to test the LiveJobRepository find method
@gregbrowndev gregbrowndev added the enhancement New feature or request label Sep 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant