Use Isolated Test Database for Reliable and Consistent Test Runs#230
Closed
avirajsingh7 wants to merge 12 commits intomainfrom
Closed
Use Isolated Test Database for Reliable and Consistent Test Runs#230avirajsingh7 wants to merge 12 commits intomainfrom
avirajsingh7 wants to merge 12 commits intomainfrom
Conversation
Codecov ReportAttention: Patch coverage is
📢 Thoughts on this report? Let us know! |
Closed
kurund
reviewed
Jun 23, 2025
docker-compose.yml
Outdated
| - POSTGRES_DB=${POSTGRES_DB?Variable not set} | ||
| - POSTGRES_DB_TEST=${POSTGRES_DB_TEST?Variable not set} | ||
| # Wait for main DB to be ready, then create test DB if it doesn't exist | ||
| command: > |
Collaborator
There was a problem hiding this comment.
I am not sure if this is needed when we start the containers. It would be good to handle this during the test run.
kurund
requested changes
Jun 23, 2025
Collaborator
kurund
left a comment
There was a problem hiding this comment.
Can you also please resolve the conflicts.
kurund
reviewed
Jun 23, 2025
backend/app/tests/conftest.py
Outdated
| with Session(engine) as session: | ||
| with Session(test_engine) as session: | ||
| # Drop all tables and recreate them | ||
| SQLModel.metadata.drop_all(test_engine) |
Collaborator
There was a problem hiding this comment.
Maybe drop the database instead of the tables.
kurund
reviewed
Jun 25, 2025
| ports: | ||
| - 5432:5432 | ||
| options: --health-cmd "pg_isready -U postgres" --health-interval 10s --health-timeout 5s --health-retries 5 | ||
| options: >- |
Collaborator
There was a problem hiding this comment.
Is this intentional?
Collaborator
Author
There was a problem hiding this comment.
@kurund was part of my previous commit where I was modifying this file.
Either way it is fine
Collaborator
There was a problem hiding this comment.
Might be good to revert then
This file contains hidden or 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
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.
Target issue : #204
This PR addresses the issue where local test cases were running against the shared development database, causing inconsistent results due to residual or missing data. The updated implementation ensures that test cases now run against a dedicated test database (POSTGRES_DB_TEST), providing a clean and repeatable environment for every test session.