-
Notifications
You must be signed in to change notification settings - Fork 0
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
Remove DatabaseSupport.clean()
from unit tests
#1327
Merged
Merged
Conversation
This file contains 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
We currently have some unit tests that fail if `DatabaseSupport.clean()` is not run before each test. This is usually due to duplicate data being added to the DB causing a constraint violation. Since we have introduced "seeders" to populate some of our reference data. It should now be possible to fix any tests that currently fail without the DB clean. This will speed up the running of the unit tests as it won't have to rebuild the DB after running some of them.
Jozzey
added
the
housekeeping
Refactoring, tidying up or other work which supports the project
label
Sep 12, 2024
The test was trying to check for an exact amount of records, which isn't possible without clearing the DB. Changed the test so that it is now checking for at least the amount of records it's expecting as that will cover it.
As the unit tests were creating and checking for bill runs in real regions. When other tests were run in parallel this unit test would intermittently fail if other unit tests created bill runs in the same region. As this service is not reliant on having the actual region data. A randomly generated ID is used for the region to prevent other tests from effecting the results.
This test was failing locally, but passing on GitHub due to a typo which should have been setting the `enableTwoPartTariffSupplementary` feature flag that most of us have set to 'true' locally to `false`.
Some tests were failing intermittently due to `duplicate key value violates unique constraint "licence_versions_external_id_unique"`
….js` Because a lot of the other tests use random regions these tests have been intermittently failing when other tests create conflicting data. We have therefore switched to using the bill runs region as this is not selected randomly so the amount of data created in this region is kept to a minimum. As few tests use this region it is relatively safe to remove test data once created without impacting other tests that may be running.
…ce.test.js` Every now and then I think that another test is doing something with the supplementary flags which is causing this test to fail. To sort out the issue I'm using a dummy region id to minimise other tests interfering with this one. I'm also clearing out the data after the test so the fake region doesn't cause any issues with other tests that may require region data for licences.
Jozzey
requested review from
Cruikshanks,
robertparkinson,
jonathangoulding and
Beckyrose200
September 25, 2024 16:07
Cruikshanks
requested changes
Sep 26, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one little NIT. But this is outstanding work!
test/services/bill-runs/two-part-tariff/fetch-charge-versions.service.test.js
Outdated
Show resolved
Hide resolved
This intermittent failure was caused because when populating `invalidSecondaryPurpose` from the helper no purpose was specified so it was using a random one. Unfortunately every now and then the random one was actually the valid one with the `legacyId` being `ELC`
Cruikshanks
approved these changes
Sep 26, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
https://eaflood.atlassian.net/browse/WATER-4677
We currently have some unit tests that fail if
DatabaseSupport.clean()
is not run before each test. This is usually due to duplicate data being added to the DB causing a constraint violation.Since we have introduced "seeders" to populate some of our reference data. It should now be possible to fix any tests that currently fail without the DB clean. This will speed up the running of the unit tests as it won't have to rebuild the DB after running some of them.