Skip to content

Commit

Permalink
Fix: reset database tables before integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderleegs committed Jan 5, 2023
1 parent 893d255 commit 5e865d2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/integration/NotificationOnEditHandler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,18 @@ describe("Notifications Router", () => {
changed_files: [],
created_at: new Date(),
})

// We need to force the relevant tables to start from a clean slate
// Otherwise, some tests may fail due to the auto-incrementing IDs
// not starting from 1
await User.sync({ force: true })
await Site.sync({ force: true })
await Repo.sync({ force: true })
await SiteMember.sync({ force: true })
await Notification.sync({ force: true })
await ReviewMeta.sync({ force: true })
await ReviewRequest.sync({ force: true })

// Set up User and Site table entries
await User.create({
id: mockIsomerUserId,
Expand Down
9 changes: 9 additions & 0 deletions src/integration/Notifications.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,15 @@ describe("Notifications Router", () => {
const MOCK_ANOTHER_SITE_MEMBER_ID = "3"

beforeAll(async () => {
// We need to force the relevant tables to start from a clean slate
// Otherwise, some tests may fail due to the auto-incrementing IDs
// not starting from 1
await User.sync({ force: true })
await Site.sync({ force: true })
await Repo.sync({ force: true })
await SiteMember.sync({ force: true })
await Notification.sync({ force: true })

// Set up User and Site table entries
await User.create({
id: mockIsomerUserId,
Expand Down
2 changes: 2 additions & 0 deletions src/integration/Reviews.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ describe("Review Requests Integration Tests", () => {
await Site.sync({ force: true })
await Repo.sync({ force: true })
await SiteMember.sync({ force: true })
await Notification.sync({ force: true })
await ReviewMeta.sync({ force: true })

await User.create(MOCK_USER_DBENTRY_ONE)
await User.create(MOCK_USER_DBENTRY_TWO)
Expand Down

0 comments on commit 5e865d2

Please sign in to comment.