Closed diegoalzate closed 4 months ago
@diegoalzate This PR needs more clarification. It is not clear to me how the exisiting seed should interact with each testing file or whether it is independent and each testing file has its own seed.
This will be part of #340
Improve Test Data Setup to Increase Test Resilience
Description:
Currently, the
seed
function in our codebase is responsible for generating and inserting seed data into the database for testing purposes. While this function serves its purpose, it can become problematic when we need to change the default seed data, as it might break existing tests or require modifications in multiple places.The problem arises because the tests are tightly coupled to the default seed data generated by the
seed
function. If we modify the seed data generation logic, we risk breaking tests that rely on the previous seed data structure or values.To make our tests more resistant to changes in the seed data and to allow for more flexibility in specifying the required data for each test case, we propose the following solution:
Proposed Solution:
Extract Seed Data Generation into Separate Functions:
generateEventData
,generateUserData
,generateGroupData
).seed
function into these separate functions.Update the
seed
Function:seed
function should no longer generate seed data directly.seed
function will then insert the provided seed data into the database using the existing helper functions (createEvent
,createCycle
, etc.).Update Tests:
seed
function.Benefits:
seed
function remains responsible for inserting the seed data into the database, separating concerns and keeping the codebase maintainable.Implementation Steps:
seed-data-generators.ts
) to host the seed data generator functions.seed
function to accept the seed data for each entity as parameters.seed
function.By adopting this solution, we can improve the resilience of our tests against changes in the seed data while maintaining a simple and maintainable codebase.