Answer the question
In order to leave comments, you need to log in
How do you rollback a database after test results?
Hey!
After the results of testing some functions, I need to roll back the database to its original state, which was before testing. The problem is that if the function under test itself works with transactions, then I cannot wrap such a test in my transaction. Because for example, postgres does not support nested transactions.
For example, I have a function that takes some values, makes a selection of other values, processes them and saves them somewhere. All I need is to check the stored values, and roll back the base. But nested transactions spoil everything.
How do you solve such a problem?
Answer the question
In order to leave comments, you need to log in
Before each test, the database is brought to its original state, the only way. Deleting nafig all tables and knurling all fixtures. Otherwise, the test results will be mixed with each other, which, to put it mildly, is a bad practice.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question