Skip to content
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

Tests should be performed on a SQLite test db #1

Open
igorbenav opened this issue Oct 5, 2023 · 5 comments
Open

Tests should be performed on a SQLite test db #1

igorbenav opened this issue Oct 5, 2023 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@igorbenav
Copy link
Owner

No description provided.

@igorbenav igorbenav added the enhancement New feature or request label Oct 5, 2023
@igorbenav
Copy link
Owner Author

Maybe just overriding the dependency will be a simpler solution with the same benefits

@mithun2003
Copy link

mithun2003 commented Feb 19, 2024

In one of our projects, we encountered an issue with a test case. The problem was identified in the following code snippet:

`async def async_get_db() -> AsyncSession:
     async_session = local_session
     async with async_session() as db:
         yield db
         db.commit()`

The last db.commit() statement was saving data to the database during test execution. Upon removing this line, the data was no longer saved during testing, and the test case started working as expected. It's worth noting that regular database data saving continued to function properly.

@igorbenav igorbenav assigned igorbenav and unassigned igorbenav Feb 19, 2024
@igorbenav
Copy link
Owner Author

Hey, @mithun2003, thanks! I'll change it. I should also fix the tests and do this migration to SQLite as soon as possible, trying to find the time

@igorbenav igorbenav self-assigned this Feb 19, 2024
@YousefAldabbas
Copy link
Contributor

hey @igorbenav
Why should tests be done using SQLite database? I know it's the "Django way of testing" but what if my application is using PostgreSQL and has a table with a JSONB column? This will cause errors in the tests
What about using a PostgreSQL database for testing with Docker and removing it once the tests are done? I'm not expert in docker but i believe its doable. what do you think?

@igorbenav
Copy link
Owner Author

Tbh I changed my mind some time after self assigning, which is why I never actually did this. Indeed I think the best way is creating a test db of the same type

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

3 participants