Skip to content

Commit

Permalink
chore: cleanup up db creation for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gentlementlegen committed Jul 4, 2024
1 parent 584ce87 commit 98e21d0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ cypress/screenshots
script.ts
.wrangler
test-dashboard.md
database/tests/*
9 changes: 4 additions & 5 deletions tests/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ const htmlUrl = "https://github.com/ubiquibot/automated-merging/pull/1";
const actionsGithubPackage = "@actions/github";

describe("Action tests", () => {
const dbName = `database/tests/${expect.getState().currentTestName}.db`;

beforeEach(() => {
jest.resetAllMocks();
jest.resetModules();
fs.rmSync(dbName, { force: true });
});

it("Should add a pull request in the DB on PR opened", async () => {
const dbName = `database/${expect.getState().currentTestName}.db`;
fs.rmSync(dbName, { force: true });
jest.mock(actionsGithubPackage, () => ({
context: {
repo: {
Expand Down Expand Up @@ -56,8 +57,6 @@ describe("Action tests", () => {
});

it("Should remove a pull request in the DB on PR closed", async () => {
const dbName = `database/${expect.getState().currentTestName}.db`;
fs.rmSync(dbName, { force: true });
const dataSource = await initializeDataSource(dbName);
const pr = new PullRequest();
pr.url = htmlUrl;
Expand Down Expand Up @@ -104,7 +103,7 @@ describe("Action tests", () => {
inputs: {
eventName: "push",
settings: JSON.stringify({
databaseUrl: `database/should_not_close_a_pr_that_is_not_past_the_threshold.db`,
databaseUrl: dbName,
}),
eventPayload: JSON.stringify({
pull_request: {
Expand Down

0 comments on commit 98e21d0

Please sign in to comment.