mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
schema analyser test
This commit is contained in:
parent
5ab686b721
commit
fc0db925c5
@ -67,3 +67,4 @@ describe('Alter database', () => {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
53
integration-tests/__tests__/schema-tests.spec.js
Normal file
53
integration-tests/__tests__/schema-tests.spec.js
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
const stableStringify = require('json-stable-stringify');
|
||||||
|
const _ = require('lodash');
|
||||||
|
const fp = require('lodash/fp');
|
||||||
|
const { testWrapper } = require('../tools');
|
||||||
|
const engines = require('../engines');
|
||||||
|
const { runCommandOnDriver } = require('dbgate-tools');
|
||||||
|
|
||||||
|
describe('Schema tests', () => {
|
||||||
|
test.each(engines.filter(x => x.supportSchemas).map(engine => [engine.label, engine]))(
|
||||||
|
'Create schema - %s',
|
||||||
|
testWrapper(async (conn, driver, engine) => {
|
||||||
|
const structure1 = await driver.analyseFull(conn);
|
||||||
|
expect(structure1.schemas.find(x => x.schemaName == 'myschema')).toBeFalsy();
|
||||||
|
await runCommandOnDriver(conn, driver, dmp => dmp.createSchema('myschema'));
|
||||||
|
const structure2 = await driver.analyseIncremental(conn, structure1);
|
||||||
|
expect(structure2.schemas.find(x => x.schemaName == 'myschema')).toBeTruthy();
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
test.each(engines.filter(x => x.supportSchemas).map(engine => [engine.label, engine]))(
|
||||||
|
'Drop schema - %s',
|
||||||
|
testWrapper(async (conn, driver, engine) => {
|
||||||
|
await runCommandOnDriver(conn, driver, dmp => dmp.createSchema('myschema'));
|
||||||
|
|
||||||
|
const structure1 = await driver.analyseFull(conn);
|
||||||
|
expect(structure1.schemas.find(x => x.schemaName == 'myschema')).toBeTruthy();
|
||||||
|
await runCommandOnDriver(conn, driver, dmp => dmp.dropSchema('myschema'));
|
||||||
|
const structure2 = await driver.analyseIncremental(conn, structure1);
|
||||||
|
expect(structure2.schemas.find(x => x.schemaName == 'myschema')).toBeFalsy();
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Base analyser test', () => {
|
||||||
|
test.each(engines.map(engine => [engine.label, engine]))(
|
||||||
|
'Structure without change - %s',
|
||||||
|
testWrapper(async (conn, driver, engine) => {
|
||||||
|
await driver.query(conn, `create table t1 (id int not null primary key)`);
|
||||||
|
|
||||||
|
await driver.query(
|
||||||
|
conn,
|
||||||
|
`create table t2 (
|
||||||
|
id int not null primary key,
|
||||||
|
t1_id int null references t1(id)
|
||||||
|
)`
|
||||||
|
);
|
||||||
|
|
||||||
|
const structure1 = await driver.analyseFull(conn);
|
||||||
|
const structure2 = await driver.analyseIncremental(conn, structure1);
|
||||||
|
expect(structure2).toBeNull();
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
@ -1,12 +1,12 @@
|
|||||||
version: '3'
|
version: '3'
|
||||||
services:
|
services:
|
||||||
# postgres:
|
postgres:
|
||||||
# image: postgres
|
image: postgres
|
||||||
# restart: always
|
restart: always
|
||||||
# environment:
|
environment:
|
||||||
# POSTGRES_PASSWORD: Pwd2020Db
|
POSTGRES_PASSWORD: Pwd2020Db
|
||||||
# ports:
|
ports:
|
||||||
# - 15000:5432
|
- 15000:5432
|
||||||
|
|
||||||
# mariadb:
|
# mariadb:
|
||||||
# image: mariadb
|
# image: mariadb
|
||||||
@ -26,13 +26,13 @@ services:
|
|||||||
# environment:
|
# environment:
|
||||||
# - MYSQL_ROOT_PASSWORD=Pwd2020Db
|
# - MYSQL_ROOT_PASSWORD=Pwd2020Db
|
||||||
|
|
||||||
clickhouse:
|
# clickhouse:
|
||||||
image: bitnami/clickhouse:24.8.4
|
# image: bitnami/clickhouse:24.8.4
|
||||||
restart: always
|
# restart: always
|
||||||
ports:
|
# ports:
|
||||||
- 15005:8123
|
# - 15005:8123
|
||||||
environment:
|
# environment:
|
||||||
- CLICKHOUSE_ADMIN_PASSWORD=Pwd2020Db
|
# - CLICKHOUSE_ADMIN_PASSWORD=Pwd2020Db
|
||||||
|
|
||||||
# mssql:
|
# mssql:
|
||||||
# image: mcr.microsoft.com/mssql/server
|
# image: mcr.microsoft.com/mssql/server
|
||||||
|
@ -81,6 +81,7 @@ const engines = [
|
|||||||
drop2: 'DROP FUNCTION obj2',
|
drop2: 'DROP FUNCTION obj2',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
supportSchemas: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'SQL Server',
|
label: 'SQL Server',
|
||||||
@ -105,6 +106,7 @@ const engines = [
|
|||||||
drop2: 'DROP PROCEDURE obj2',
|
drop2: 'DROP PROCEDURE obj2',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
supportSchemas: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'SQLite',
|
label: 'SQLite',
|
||||||
@ -159,11 +161,11 @@ const filterLocal = [
|
|||||||
// filter local testing
|
// filter local testing
|
||||||
'-MySQL',
|
'-MySQL',
|
||||||
'-MariaDB',
|
'-MariaDB',
|
||||||
'-PostgreSQL',
|
'PostgreSQL',
|
||||||
'-SQL Server',
|
'-SQL Server',
|
||||||
'-SQLite',
|
'-SQLite',
|
||||||
'-CockroachDB',
|
'-CockroachDB',
|
||||||
'ClickHouse',
|
'-ClickHouse',
|
||||||
];
|
];
|
||||||
|
|
||||||
const enginesPostgre = engines.filter(x => x.label == 'PostgreSQL');
|
const enginesPostgre = engines.filter(x => x.label == 'PostgreSQL');
|
||||||
|
Loading…
Reference in New Issue
Block a user