diff --git a/tests/integration/api/v1/migrations/get.test.js b/tests/integration/api/v1/migrations/get.test.js index 898f607..e772335 100644 --- a/tests/integration/api/v1/migrations/get.test.js +++ b/tests/integration/api/v1/migrations/get.test.js @@ -1,8 +1,7 @@ -import database from "infra/database"; import orchestrator from "tests/orchestrator.js"; beforeAll(async () => { await orchestrator.waitForAllServices(); - await database.query("drop schema public cascade; create schema public;"); + await orchestrator.clearDatabase(); }); describe("GET /api/v1/migrations", () => { diff --git a/tests/integration/api/v1/migrations/post.test.js b/tests/integration/api/v1/migrations/post.test.js index 0947e09..5ba6bcb 100644 --- a/tests/integration/api/v1/migrations/post.test.js +++ b/tests/integration/api/v1/migrations/post.test.js @@ -1,8 +1,7 @@ -import database from "infra/database"; import orchestrator from "tests/orchestrator.js"; beforeAll(async () => { await orchestrator.waitForAllServices(); - await database.query("drop schema public cascade; create schema public;"); + await orchestrator.clearDatabase(); }); describe("POST /api/v1/migrations", () => { @@ -38,4 +37,4 @@ describe("POST /api/v1/migrations", () => { }); }); }); -}); \ No newline at end of file +}); diff --git a/tests/orchestrator.js b/tests/orchestrator.js index a2a7829..42c90e6 100644 --- a/tests/orchestrator.js +++ b/tests/orchestrator.js @@ -1,4 +1,6 @@ import retry from "async-retry"; +import database from "infra/database"; + async function waitForAllServices() { await waitForWebServer(); @@ -19,7 +21,13 @@ async function waitForAllServices() { } } } + +async function clearDatabase() { + await database.query("drop schema public cascade; create schema public;"); +} + const orchestrator = { waitForAllServices, + clearDatabase, }; export default orchestrator;