M
M
memba2016-11-14 17:58:11
go
memba, 2016-11-14 17:58:11

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

2 answer(s)
I
index0h, 2016-11-14
@index0h

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.

A
Andrey Vorobyov, 2016-11-27
@Santacruz

drop scheme public; create scheme public

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question