Skip to content

Commit

Permalink
refactor: use orchestrator.cleanDatabase() in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AlAnNuB authored Sep 11, 2024
1 parent 10d8cdb commit 9002aea
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.test.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.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,9 +1,8 @@
import database from "infra/database.js";
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
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 @@ -18,7 +19,12 @@ 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 9002aea

Please sign in to comment.