Skip to content
Snippets Groups Projects
Commit d670884a authored by Jure's avatar Jure
Browse files

test: different db-readiness approach

parent a15bc025
No related branches found
No related tags found
No related merge requests found
const logger = require('@pubsweet/logger')
// const { Journal, User } = require('@pubsweet/models')
const { createTables, db } = require('@pubsweet/db-manager')
const wait = require('waait')
const clearDb = async () => {
const { rows } = await db.raw(`
......@@ -43,17 +42,16 @@ const seed = async dumpSql => {
// TODO: This wait is necessary for the database to "settle".
while (!ready) {
// eslint-disable-next-line
const { rows } = await db.raw(`SELECT EXISTS (
SELECT FROM information_schema.tables
WHERE table_schema = 'public'
AND table_name = 'users'
);`)
if (rows && rows[0] && rows[0].exists) {
ready = true
const result = await db.raw(`set search_path to 'public';`)
const { User } = require('@pubsweet/models')
try {
// eslint-disable-next-line
const users = await User.query()
ready = !!users
} catch (e) {
// eslint-disable-next-line
console.log(e)
}
// eslint-disable-next-line
await wait(1000)
}
return true
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment