Tests should be performed on a SQLite test db
Maybe just overriding the dependency will be a simpler solution with the same benefits
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.
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
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?
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