mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-18 00:56:02 +00:00
import SQL dump tests
This commit is contained in:
@@ -3,6 +3,7 @@ const stream = require('stream');
|
|||||||
const { testWrapper } = require('../tools');
|
const { testWrapper } = require('../tools');
|
||||||
const tableWriter = require('dbgate-api/src/shell/tableWriter');
|
const tableWriter = require('dbgate-api/src/shell/tableWriter');
|
||||||
const copyStream = require('dbgate-api/src/shell/copyStream');
|
const copyStream = require('dbgate-api/src/shell/copyStream');
|
||||||
|
const importDatabase = require('dbgate-api/src/shell/importDatabase');
|
||||||
const fakeObjectReader = require('dbgate-api/src/shell/fakeObjectReader');
|
const fakeObjectReader = require('dbgate-api/src/shell/fakeObjectReader');
|
||||||
|
|
||||||
function createImportStream() {
|
function createImportStream() {
|
||||||
@@ -72,4 +73,29 @@ describe('DB Import', () => {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
test.each(engines.filter(x => x.dumpFile).map(engine => [engine.label, engine]))(
|
||||||
|
'Import SQL dump - %s',
|
||||||
|
testWrapper(async (conn, driver, engine) => {
|
||||||
|
// const reader = await fakeObjectReader({ delay: 10 });
|
||||||
|
// const reader = await fakeObjectReader();
|
||||||
|
await importDatabase({
|
||||||
|
systemConnection: conn,
|
||||||
|
driver,
|
||||||
|
inputFile: engine.dumpFile,
|
||||||
|
});
|
||||||
|
|
||||||
|
const structure = await driver.analyseFull(conn);
|
||||||
|
|
||||||
|
for (const check of engine.dumpChecks || []) {
|
||||||
|
const res = await driver.query(conn, check.sql);
|
||||||
|
expect(res.rows[0].res.toString()).toEqual(check.res);
|
||||||
|
}
|
||||||
|
|
||||||
|
// const res1 = await driver.query(conn, `select count(*) as cnt from t1`);
|
||||||
|
// expect(res1.rows[0].cnt.toString()).toEqual('6');
|
||||||
|
|
||||||
|
// const res2 = await driver.query(conn, `select count(*) as cnt from t2`);
|
||||||
|
// expect(res2.rows[0].cnt.toString()).toEqual('6');
|
||||||
|
})
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
15963
integration-tests/data/chinook-mysql.sql
Normal file
15963
integration-tests/data/chinook-mysql.sql
Normal file
File diff suppressed because it is too large
Load Diff
16173
integration-tests/data/chinook-postgre.sql
Normal file
16173
integration-tests/data/chinook-postgre.sql
Normal file
File diff suppressed because it is too large
Load Diff
@@ -8,14 +8,14 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- 15000:5432
|
- 15000:5432
|
||||||
|
|
||||||
# mariadb:
|
mariadb:
|
||||||
# image: mariadb
|
image: mariadb
|
||||||
# command: --default-authentication-plugin=mysql_native_password
|
command: --default-authentication-plugin=mysql_native_password
|
||||||
# restart: always
|
restart: always
|
||||||
# ports:
|
ports:
|
||||||
# - 15004:3306
|
- 15004:3306
|
||||||
# environment:
|
environment:
|
||||||
# - MYSQL_ROOT_PASSWORD=Pwd2020Db
|
- MYSQL_ROOT_PASSWORD=Pwd2020Db
|
||||||
|
|
||||||
# mysql:
|
# mysql:
|
||||||
# image: mysql:8.0.18
|
# image: mysql:8.0.18
|
||||||
|
|||||||
@@ -30,6 +30,13 @@ const engines = [
|
|||||||
// skipOnCI: true,
|
// skipOnCI: true,
|
||||||
objects: [views],
|
objects: [views],
|
||||||
dbSnapshotBySeconds: true,
|
dbSnapshotBySeconds: true,
|
||||||
|
dumpFile: 'data/chinook-mysql.sql',
|
||||||
|
dumpChecks: [
|
||||||
|
{
|
||||||
|
sql: 'select count(*) as res from genre',
|
||||||
|
res: '25',
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'MariaDB',
|
label: 'MariaDB',
|
||||||
@@ -47,6 +54,13 @@ const engines = [
|
|||||||
skipOnCI: true,
|
skipOnCI: true,
|
||||||
objects: [views],
|
objects: [views],
|
||||||
dbSnapshotBySeconds: true,
|
dbSnapshotBySeconds: true,
|
||||||
|
dumpFile: 'data/chinook-mysql.sql',
|
||||||
|
dumpChecks: [
|
||||||
|
{
|
||||||
|
sql: 'select count(*) as res from genre',
|
||||||
|
res: '25',
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'PostgreSQL',
|
label: 'PostgreSQL',
|
||||||
@@ -83,6 +97,13 @@ const engines = [
|
|||||||
],
|
],
|
||||||
supportSchemas: true,
|
supportSchemas: true,
|
||||||
defaultSchemaName: 'public',
|
defaultSchemaName: 'public',
|
||||||
|
dumpFile: 'data/chinook-postgre.sql',
|
||||||
|
dumpChecks: [
|
||||||
|
{
|
||||||
|
sql: 'select count(*) as res from "public"."Genre"',
|
||||||
|
res: '25',
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'SQL Server',
|
label: 'SQL Server',
|
||||||
@@ -164,10 +185,10 @@ const engines = [
|
|||||||
const filterLocal = [
|
const filterLocal = [
|
||||||
// filter local testing
|
// filter local testing
|
||||||
'-MySQL',
|
'-MySQL',
|
||||||
'-MariaDB',
|
'MariaDB',
|
||||||
'-PostgreSQL',
|
'PostgreSQL',
|
||||||
'-SQL Server',
|
'-SQL Server',
|
||||||
'SQLite',
|
'-SQLite',
|
||||||
'-CockroachDB',
|
'-CockroachDB',
|
||||||
'-ClickHouse',
|
'-ClickHouse',
|
||||||
];
|
];
|
||||||
|
|||||||
Reference in New Issue
Block a user