Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
codetheweb committed Apr 9, 2024
1 parent 26123da commit 87eacd3
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 13 deletions.
35 changes: 35 additions & 0 deletions src/tests/cleanup/does-database-exist.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import test from "ava"
import pRetry from "p-retry"
import { getTestPostgresDatabaseFactory } from "~/index"

const getTestServer = getTestPostgresDatabaseFactory({
postgresVersion: process.env.POSTGRES_VERSION,
})

const NUM_OF_DEFAULT_POSTGRES_DATABASES = 1

test("database that first test worker created should have been dropped", async (t) => {
const { pool } = await getTestServer(t)

await pRetry(
async () => {
const {
rows: [{ count }],
} = await pool.query(
'SELECT COUNT(*) FROM "pg_database" WHERE "datistemplate" = false'
)

// (Add one since we create a database in this test)
if (Number(count) !== NUM_OF_DEFAULT_POSTGRES_DATABASES + 1) {
throw new Error("Database was not dropped")
}
},
{
minTimeout: 100,
factor: 1,
maxRetryTime: 30_000,
}
)

t.pass()
})
1 change: 0 additions & 1 deletion src/tests/hooks.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import test from "ava"
import { getTestPostgresDatabaseFactory } from "~/index"
import { countDatabaseTemplates } from "./utils/count-database-templates"
import { doesDatabaseExist } from "./utils/does-database-exist"

test("beforeTemplateIsBaked", async (t) => {
let wasHookCalled = false
Expand Down
12 changes: 0 additions & 12 deletions src/tests/utils/does-database-exist.ts

This file was deleted.

0 comments on commit 87eacd3

Please sign in to comment.