Browse Source

fix(playwright): AsyncDatabase

pull/5903/head
Wing-Kam Wong 1 year ago
parent
commit
b8da41dae2
  1. 10
      tests/playwright/setup/db.ts
  2. 6
      tests/playwright/setup/sqliteExec.ts

10
tests/playwright/setup/db.ts

@ -2,8 +2,7 @@ import { NcContext } from '.';
const mysql = require('mysql2');
const { Client } = require('pg');
import { PromisedDatabase } from 'promised-sqlite3';
const sqliteDb = new PromisedDatabase();
import { AsyncDatabase } from 'promised-sqlite3';
const isMysql = (context: NcContext) => context.dbType === 'mysql';
@ -53,12 +52,15 @@ const mysqlExec = async query => {
};
async function sqliteExec(query) {
try {
const parallelIndex = process.env.TEST_PARALLEL_INDEX;
const rootProjectDir = __dirname.replace('/tests/playwright/setup', '');
await sqliteDb.open(`${rootProjectDir}/packages/nocodb/test_sakila_${parallelIndex}.db`);
const sqliteDb = await AsyncDatabase.open(`${rootProjectDir}/packages/nocodb/test_sakila_${parallelIndex}.db`);
await sqliteDb.run(query);
await sqliteDb.close();
} catch (err) {
console.error(err);
}
}
export { sqliteExec, mysqlExec, isMysql, isSqlite, isPg, pgExec };

6
tests/playwright/setup/sqliteExec.ts

@ -1,10 +1,8 @@
const { PromisedDatabase } = require('promised-sqlite3');
const sqliteDb = new PromisedDatabase();
import { AsyncDatabase } from 'promised-sqlite3';
async function sqliteExec(query) {
const rootProjectDir = __dirname.replace('/scripts/playwright/setup', '');
await sqliteDb.open(`${rootProjectDir}/packages/nocodb/test_noco.db`);
const sqliteDb = await AsyncDatabase.open(`${rootProjectDir}/packages/nocodb/test_noco.db`);
await sqliteDb.run(query);
}

Loading…
Cancel
Save