2021-02-25 07:22:24 -05:00
|
|
|
const { exec } = require('child_process')
|
|
|
|
const { waitForDb, db } = require('../../../../app/src/infrastructure/mongodb')
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
initialize() {
|
|
|
|
before(waitForDb)
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
before(function (done) {
|
2021-02-25 07:22:24 -05:00
|
|
|
exec('bin/east migrate', (error, stdout, stderr) => {
|
|
|
|
if (error) {
|
|
|
|
throw error
|
|
|
|
}
|
|
|
|
done()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
afterEach(async function () {
|
2021-02-25 07:22:24 -05:00
|
|
|
return Promise.all(
|
2021-05-17 05:37:23 -04:00
|
|
|
Object.values(db).map(async collection => {
|
|
|
|
if (collection === db.migrations) {
|
|
|
|
// Do not clear the collection for tracking migrations.
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return collection.deleteMany({})
|
|
|
|
})
|
2021-02-25 07:22:24 -05:00
|
|
|
)
|
|
|
|
})
|
2021-04-27 03:52:58 -04:00
|
|
|
},
|
2021-02-25 07:22:24 -05:00
|
|
|
}
|