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

fix: Ensure the DB is still "cleaned" even when transactions are not used #109

Merged
merged 1 commit into from
Jan 15, 2021

Conversation

skalar-bcawkwell
Copy link
Contributor

In some tests, we might ensure that a transaction has been rolled back (e.g. if
an error occurred). Since currently we do not support transactions within other
transactions, those tests use the omit_database_transaction flag which means
the test does not get wrapped in a transaction. The problem is that these tests
now leave data lying around after running.

Our original plan to solve this was to find a way to still rollback in the app
despite already running in a transaction. However Sequel does not support naming
a transaction from what I can tell, and anyway there is no way to pass args to
the transaction via the DatabaseCleaner gem. Going through some issues I found
this issue:
DatabaseCleaner/database_cleaner#652

Basically this person wants to read data from the DB in another app, but in only
some tests. He took the approach of switching "strategy" to accomplish it. I am
basically stealing the same idea since it seems to work and was quite trivial.
The big downside is that those tests will probably take longer to run, luckily
only 5 tests use this flag currently in echo, so this should not be too big of a
problem.

…used

In some tests, we might ensure that a transaction has been rolled back (e.g. if
an error occurred). Since currently we do not support transactions within other
transactions, those tests use the `omit_database_transaction` flag which means
the test does not get wrapped in a transaction. The problem is that these tests
now leave data lying around after running.

Our original plan to solve this was to find a way to still rollback in the app
despite already running in a transaction. However Sequel does not support naming
a transaction from what I can tell, and anyway there is no way to pass args to
the transaction via the `DatabaseCleaner` gem. Going through some issues I found
this issue:
  DatabaseCleaner/database_cleaner#652

Basically this person wants to read data from the DB in another app, but in only
some tests. He took the approach of switching "strategy" to accomplish it. I am
basically stealing the same idea since it seems to work and was quite trivial.
The big downside is that those tests will probably take longer to run, luckily
only 5 tests use this flag currently in echo, so this should not be too big of a
problem.
@skalar-bcawkwell skalar-bcawkwell merged commit ae98f1b into master Jan 15, 2021
@skalar-bcawkwell skalar-bcawkwell deleted the purge-db branch January 15, 2021 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants