schireson / pytest-mock-resources

Pytest Fixtures that let you actually test against external resource (Postgres, Mongo, Redshift...) dependent code.
https://pytest-mock-resources.readthedocs.io/en/latest/quickstart.html
MIT License
179 stars 19 forks source link

feat: Add `cleanup_database` option to postgres fixture. #219

Open DanCardin opened 1 week ago

DanCardin commented 1 week ago

Note, this could potentially reveal preexisting issues in code under test, that could be perceived as a "breaking" change.

By deleting the database under test at the end of the test's execution, any database connections left connected to the database might cause the DELETE DATABASE command to fail.

PMR will try to use the WITH FORCE option on database versions >= 13.0, but that option does not exist on prior versions of postgres.

In any case, if this happens, it is ultimately revealing a "bug" in the code it is testing. Additionally, you can simply turn off database cleanup in one of various ways.

coveralls commented 1 week ago

Pull Request Test Coverage Report for Build 10910050763

Details


Changes Missing Coverage Covered Lines Changed/Added Lines %
src/pytest_mock_resources/fixture/postgresql.py 27 28 96.43%
<!-- Total: 37 38 97.37% -->
Totals Coverage Status
Change from base Build 10907347726: 0.2%
Covered Lines: 1506
Relevant Lines: 1657

💛 - Coveralls