-
Notifications
You must be signed in to change notification settings - Fork 197
/
Copy pathsetup.ts
33 lines (28 loc) · 881 Bytes
/
setup.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { default as db, sequencerDB } from '../src/helpers/mysql';
export const TEST_DATABASE_SUFFIX = '_test';
const setup = async () => {
try {
await db.queryAsync('SELECT 1 + 1');
await sequencerDB.queryAsync('SELECT 1 + 1');
if (db.config.connectionConfig.database.endsWith(TEST_DATABASE_SUFFIX)) {
throw new Error(
`Hub database name is not ending by ${TEST_DATABASE_SUFFIX}`
);
}
if (
sequencerDB.config.connectionConfig.database.endsWith(
TEST_DATABASE_SUFFIX
)
) {
throw new Error(
`Sequencer database name is not ending by ${TEST_DATABASE_SUFFIX}`
);
}
} catch (e: any) {
if (e.code === 'ER_BAD_DB_ERROR') {
console.error('Test database not setup, please run `yarn test:setup`');
throw new Error('Test database not setup');
}
}
};
export default setup;