As you roll back the database after the test results?

Hi!

After the results of testing some functions I need to roll back the database to its original state prior to testing. The problem is that if the test function works with transactions, I can't wrap this test in its transaction. Because for example, postgres does not support nested transactions.

For example, I have a function that takes some value, selects other values, processes them and stores them somewhere. All I need is to check the stored values, and roll back the database. But nested transactions ruin everything.

How do you solve such a problem?
July 2nd 19 at 16:59
2 answers
July 2nd 19 at 17:01
Before each test, the database can operate to its original state, the only way. Remove nafig all tables and rolling all fixtures. Otherwise the test results will be mixed, to put it mildly - crap practice.
Yes, fixtures that decision, but it is very expensive. I have a 10GB DB, 100+ tables, views, etc. It changes almost every day that I migration do not have time to roll. With the fixture my work is reduced to their constant change. - Selmer_Berge43 commented on July 2nd 19 at 17:04

> Yes, the fixtures this decision, but it is very expensive.
only one

> I have a DB on 10GB, there are 100+ tables, views, etc.
Who cares how much it weighs the prod database?)

> It changes almost every day that I migration do not have time to roll.
Actually Cho is?)) You are responsible for all tables?

> With the fixture my work is reduced to their constant change.
If you change the structure of the database, or code it handles changes and tests with test data, obviously. - andre_Erdman43 commented on July 2nd 19 at 17:07
Make a mold of the file system. Snapshot. Then just rolled back on the diff to the old snapshot. - Alyson.McClure commented on July 2nd 19 at 17:10
July 2nd 19 at 17:03
drop scheme public; create public scheme

Find more questions by tags Go