The current test implementation for the repository layer does not provide sufficient cleanup in the Cleanup phase. This causes data from previous tests to persist, which leads to unexpected results and failures when subsequent tests are executed. Proper test isolation is crucial to ensuring that each test can run independently without being affected by the state of other tests. This issue aims to refactor the tests by enhancing the Cleanup phase and ensuring that no test data persists after each test execution.
Goal
This issue will be considered closed when the following conditions are met:
Enhanced Cleanup Phase:
Each test's Cleanup phase properly removes all test data and reinitializes the database state, ensuring no residual data from previous tests.
Test Isolation:
Each test can be executed independently without interference from other tests.
Verification of Correctness:
All existing tests pass successfully after the refactor with proper cleanup and isolation.
Todo
[ ] Refactor the existing tests to include a comprehensive cleanup phase that clears any residual test data.
[ ] Create a clearDatabase() function to be used in each test's Cleanup phase.
[ ] Validate that the clearDatabase() function is invoked in each test after the validation phase.
[ ] Ensure that no data is carried over between tests by adding assertions to check the initial state before each test run.
Summary
The current test implementation for the repository layer does not provide sufficient cleanup in the Cleanup phase. This causes data from previous tests to persist, which leads to unexpected results and failures when subsequent tests are executed. Proper test isolation is crucial to ensuring that each test can run independently without being affected by the state of other tests. This issue aims to refactor the tests by enhancing the Cleanup phase and ensuring that no test data persists after each test execution.
Goal
This issue will be considered closed when the following conditions are met:
Enhanced Cleanup Phase:
Test Isolation:
Verification of Correctness:
Todo
clearDatabase()
function to be used in each test's Cleanup phase.clearDatabase()
function is invoked in each test after the validation phase.Deadline
10/7
References
https://qiita.com/ppco/items/2a7af591eaf08bdf9406 https://github.com/okuda-seminar/X-Clone-Backend/blob/main/api/handlers/setup_test.go