Skip to content

Commit

Permalink
refactor: use orchestrator.clearDatabase() in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
felipemaion authored Oct 23, 2024
1 parent 142807b commit 0eb1ffa
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
3 changes: 1 addition & 2 deletions tests/integration/api/v1/migrations/get.test.js
Original file line number Diff line number Diff line change
@@ -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", () => {
Expand Down
3 changes: 1 addition & 2 deletions tests/integration/api/v1/migrations/post.test.js
Original file line number Diff line number Diff line change
@@ -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", () => {
Expand Down
8 changes: 8 additions & 0 deletions tests/orchestrator.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import retry from "async-retry";
import database from "infra/database";

async function waitForAllServices() {
await waitForWebServer();

Expand All @@ -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;

0 comments on commit 0eb1ffa

Please sign in to comment.