Skip to content

Commit

Permalink
close connection pool after tests (hack)
Browse files Browse the repository at this point in the history
  • Loading branch information
raimohanska committed Oct 17, 2021
1 parent d10e10f commit b07f983
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions backend/src/db.ts
Expand Up @@ -14,6 +14,10 @@ const pgConfig = {
}
const connectionPool = new pg.Pool(pgConfig)

export function closeConnectionPool() {
connectionPool.end()
}

export async function initDB(backendDir: string = ".") {
console.log("Running database migrations")
await inTransaction((client) =>
Expand Down
4 changes: 3 additions & 1 deletion integration/src/compact-history.test.ts
Expand Up @@ -2,7 +2,7 @@ import { addHours, addSeconds } from "date-fns"
import _ from "lodash"
import { createBoard, getBoardHistoryBundleMetas, storeEventHistoryBundle } from "../../backend/src/board-store"
import { quickCompactBoardHistory } from "../../backend/src/compact-history"
import { initDB, inTransaction, withDBClient } from "../../backend/src/db"
import { initDB, inTransaction, closeConnectionPool, withDBClient } from "../../backend/src/db"
import { BoardHistoryEntry, EventUserInfo, Id, newBoard, Serial } from "../../common/src/domain"
type BundleDesc = [Date, Serial, Serial]
describe("quick compact", () => {
Expand Down Expand Up @@ -90,6 +90,8 @@ describe("quick compact", () => {
[laterSave, 8, 8],
])
})

afterAll(closeConnectionPool)
})

async function storeBundles(boardId: Id, bundles: BundleDesc[]) {
Expand Down

0 comments on commit b07f983

Please sign in to comment.