From 41e55f329cf3e41c14e1751a3846c8311c7d5ebc Mon Sep 17 00:00:00 2001 From: Jan Prochazka Date: Thu, 27 May 2021 09:43:08 +0200 Subject: [PATCH] temp dir --- integration-tests/.gitignore | 1 + integration-tests/__tests__/analyse.spec.js | 46 +++++++++++++-------- integration-tests/dbtemp/.gitkeep | 0 integration-tests/engines.js | 7 ++++ 4 files changed, 36 insertions(+), 18 deletions(-) create mode 100644 integration-tests/.gitignore create mode 100644 integration-tests/dbtemp/.gitkeep diff --git a/integration-tests/.gitignore b/integration-tests/.gitignore new file mode 100644 index 00000000..b73d19b2 --- /dev/null +++ b/integration-tests/.gitignore @@ -0,0 +1 @@ +dbtemp \ No newline at end of file diff --git a/integration-tests/__tests__/analyse.spec.js b/integration-tests/__tests__/analyse.spec.js index a198b523..599b04a8 100644 --- a/integration-tests/__tests__/analyse.spec.js +++ b/integration-tests/__tests__/analyse.spec.js @@ -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); diff --git a/integration-tests/dbtemp/.gitkeep b/integration-tests/dbtemp/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/integration-tests/engines.js b/integration-tests/engines.js index 25e0e1a9..8565670a 100644 --- a/integration-tests/engines.js +++ b/integration-tests/engines.js @@ -29,6 +29,13 @@ const engines = [ port: 15002, }, }, + { + label: 'SQLite', + generateDbFile: true, + connection: { + engine: 'sqlite@dbgate-plugin-sqlite', + }, + }, ]; module.exports = engines;