-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: jest setup and teardown sqlite adjustments
- Loading branch information
Showing
5 changed files
with
26 additions
and
66 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,13 @@ | ||
const detectPort = require('detect-port'); | ||
const { config } = require('dotenv'); | ||
const { join } = require('path'); | ||
const { promisify } = require('util'); | ||
const { exec } = require('child_process'); | ||
|
||
module.exports = async () => { | ||
const port = 5432; | ||
const freePort = await promisify(detectPort)(port); | ||
const cwd = join(__dirname, '..'); | ||
|
||
config(); | ||
|
||
if (freePort === port) { | ||
await promisify(exec)('npm run migration:up', { cwd }); | ||
} | ||
await promisify(exec)('npm run migration:up', { | ||
cwd: join(__dirname, '..'), | ||
stdio: 'inherit' | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,18 @@ | ||
const { default: config } = require('../src/mikro-orm.config'); | ||
const isCi = require('is-ci'); | ||
const { MikroORM } = require('@mikro-orm/core'); | ||
const { join } = require('path'); | ||
|
||
module.exports = async () => { | ||
const cwd = join(__dirname, '..'); | ||
if (isCi) { | ||
return; | ||
} | ||
|
||
if (!isCi) { | ||
let orm; | ||
try { | ||
orm = await MikroORM.init(config); | ||
let orm; | ||
try { | ||
orm = await MikroORM.init(config); | ||
|
||
await orm.em | ||
.getConnection() | ||
.execute('delete from "user" where "id" != 1;'); | ||
} finally { | ||
await orm?.close(); | ||
} | ||
await orm.em.getConnection().execute('delete from "user" where "id" > 5;'); | ||
} finally { | ||
await orm?.close(); | ||
} | ||
}; |