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
joseallef authored Sep 14, 2024
1 parent b9dd19c commit 9a24eb4
Show file tree
Hide file tree
Showing 3 changed files with 9 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,10 +1,9 @@
/* eslint-disable jest/no-commented-out-tests */
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,10 +1,9 @@
/* eslint-disable jest/no-commented-out-tests */
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
7 changes: 7 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,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 9a24eb4

Please sign in to comment.