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
brunoh5 committed Jan 4, 2025
1 parent 4b77113 commit b469f9c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
3 changes: 1 addition & 2 deletions tests/integration/api/v1/migrations/get.spec.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import database from "infra/database.js";
import orchestrator from "tests/orchestrator";

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.spec.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import database from "infra/database.js";
import orchestrator from "tests/orchestrator";

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
6 changes: 6 additions & 0 deletions tests/orchestrator.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import retry from "async-retry";
import database from "infra/database.js";

async function waitForAllServices() {
await waitForWebServer();
Expand All @@ -19,8 +20,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 b469f9c

Please sign in to comment.