There are in a simplified form on the server such endpoints:
GET /users POST /users — создание пользователя GET /users/{id} DELETE /users/{id} Server and client on the same server. Base for testing sqlite they have in common. Let's say for every endpoint I have a test. In each test, an http request is sent to the endpoint using the http client, as if the consumer (consumer) did, and the answer to correctness is checked. Before the very beginning of the tests, an empty database is created and the migration is rolled. After the tests, the base is deleted.
My problem is that before each test you need to create 7 users with fake data. And after the test so that they are "removed". And on the next test again the same creation-delete chain.
At first I did it through database transactions, that is, the test starts and starts a transaction on the client, 7 users are created, in the test there is an http request for GET / users, but there is no empty database on the server of the transaction. Therefore, this option disappears.
If you do without a transaction, then on the client and the server, due to the fact that the total database has the same data, but I need only 7 users before each test, so that previous manipulations with the database do not distort the data. Therefore, this option also disappears.
I tried the option where the removal of the database and the migration before each test is done. It works but for a very long time (a minute is needed to check 4 endpoints). In memory the database here would be sped up strongly, but here the same problem as with the transaction.
I just can not find a solution. What can you advise? I want to test all endpoints not through functional tests inside the code, but from the outside (as the interface is tested through selenium).