This commit is contained in:
Jan Prochazka 2021-05-27 09:43:08 +02:00
parent 73d3d00e9d
commit 41e55f329c
4 changed files with 36 additions and 18 deletions

1
integration-tests/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
dbtemp

View File

@ -10,25 +10,35 @@ function randomDbName() {
return `db${newKey}`;
}
async function connect(connection, database) {
async function connect(engine, database) {
const { connection } = engine;
const driver = requireEngineDriver(connection);
const conn = await driver.connect(connection);
await driver.query(conn, `CREATE DATABASE ${database}`);
await driver.close(conn);
const res = await driver.connect({
...connection,
database,
});
return res;
if (engine.generateDbFile) {
const conn = await driver.connect({
...connection,
databaseFile: `dbtemp/${database}`,
});
return conn;
} else {
const conn = await driver.connect(connection);
await driver.query(conn, `CREATE DATABASE ${database}`);
await driver.close(conn);
const res = await driver.connect({
...connection,
database,
});
return res;
}
}
describe('Analyse tests', () => {
test.each(engines.map(engine => [engine.label, engine.connection]))(
'Table - full analysis (%s)',
async (label, connection) => {
const conn = await connect(connection, randomDbName());
const driver = requireEngineDriver(connection);
test.each(engines.map(engine => [engine.label, engine]))(
'Table structure - full analysis (%s)',
async (label, engine) => {
const conn = await connect(engine, randomDbName());
const driver = requireEngineDriver(engine.connection);
await driver.query(conn, 'CREATE TABLE t1 (id int)');
@ -49,11 +59,11 @@ describe('Analyse tests', () => {
}
);
test.each(engines.map(engine => [engine.label, engine.connection]))(
test.each(engines.map(engine => [engine.label, engine]))(
'Table add - incremental analysis (%s)',
async (label, connection) => {
const conn = await connect(connection, randomDbName());
const driver = requireEngineDriver(connection);
async (label, engine) => {
const conn = await connect(engine, randomDbName());
const driver = requireEngineDriver(engine.connection);
await driver.query(conn, 'CREATE TABLE t1 (id int)');
const structure1 = await driver.analyseFull(conn);

View File

View File

@ -29,6 +29,13 @@ const engines = [
port: 15002,
},
},
{
label: 'SQLite',
generateDbFile: true,
connection: {
engine: 'sqlite@dbgate-plugin-sqlite',
},
},
];
module.exports = engines;