mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 04:27:21 +00:00
pg test: change is running check approach
This commit is contained in:
@@ -25,7 +25,10 @@ async function cleanDatabase(connection: InstanceType<typeof PostgresConnection>
|
|||||||
|
|
||||||
async function isPostgresRunning() {
|
async function isPostgresRunning() {
|
||||||
try {
|
try {
|
||||||
await $`docker exec bknd-test-postgres pg_isready -U ${credentials.user}`;
|
// Try to actually connect to PostgreSQL
|
||||||
|
const conn = pg(credentials);
|
||||||
|
await conn.ping();
|
||||||
|
await conn.close();
|
||||||
return true;
|
return true;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return false;
|
return false;
|
||||||
@@ -44,7 +47,9 @@ describe("postgres", () => {
|
|||||||
});
|
});
|
||||||
afterAll(async () => {
|
afterAll(async () => {
|
||||||
if (await isPostgresRunning()) {
|
if (await isPostgresRunning()) {
|
||||||
await $`docker stop bknd-test-postgres`;
|
try {
|
||||||
|
await $`docker stop bknd-test-postgres`;
|
||||||
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
enableConsoleLog();
|
enableConsoleLog();
|
||||||
|
|||||||
Reference in New Issue
Block a user