-
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
Create seeder for charge_categories
#1312
Conversation
Currently with the way data is being inserted into `charge_categories` using the helper to create records during unit testing. We are getting intermittent failures when running the unit tests when the charge `reference` gets duplicated due to it's lack of randomness. We have therefore decided that since the data in `charge_categories` is reference data we shouldn't really be creating a new charge category records each time a unit test requires one. Instead we should just be seeding the data once and then writing the unit tests to use this seeded data. The bulk of this work has been done for other tables in this PR #1230
I pulled the first lot of seed data from my local DB then figured it would be better to get it from Pre-prod
The amount of data that is in the `charge_categories` table now that the data is seeded is causing this test to hang. Switching to the `regions` table that has less data in resolves the issue.
I initially removed `DatabaseSupport.clean()` from the test files that I updated. However this appeared to open a bit of a can of worms. Whilst the tests that I'd amended ran fine it was having an effect on other tests causing intermittent failures. So I think it's best to leave removing the DB cleanup for another PR.
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.
Looks good
@@ -0,0 +1,33 @@ | |||
'use strict' | |||
|
|||
const { timestampForPostgres } = require('../../app/lib/general.lib.js') |
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 a nit, I think this needs to be below line 5
* - `maxVolume` - 5000, | ||
* - `dateCreated` - Date.now() | ||
* So, they are seeded automatically when tests are run. Tests that need to link to a record can use this method to | ||
* select a specific entry, or have it it return one at random. |
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.
* select a specific entry, or have it it return one at random. | |
* select a specific entry, or have it return one at random. |
Currently, with the way data is being inserted into
charge_categories
using the helper to create records during unit testing. We are getting intermittent failures when running the unit tests when the chargereference
gets duplicated due to its lack of randomness.We have therefore decided that since the data in
charge_categories
is reference data we shouldn't be creating new charge category records each time a unit test requires one. Instead, we should just be seeding the data once and then writing the unit tests to use this seeded data. The bulk of this work has been done for other tables in this PR #1230This PR will create the functions required to seed the
charge_categories
and then fix any code affected by this change.