table analyse test WIP

This commit is contained in:
Jan Prochazka
2024-09-13 16:30:48 +02:00
parent a88a64710b
commit 08dd2ae38f
2 changed files with 15 additions and 8 deletions

View File

@@ -14,19 +14,23 @@ const txMatch = (engine, tname, vcolname, nextcol) =>
expect.objectContaining({ expect.objectContaining({
columnName: 'id', columnName: 'id',
notNull: true, notNull: true,
dataType: expect.stringMatching(/int/i), dataType: expect.stringMatching(/int.*/i),
}), }),
expect.objectContaining({ expect.objectContaining({
columnName: vcolname, columnName: vcolname,
notNull: false, notNull: false,
dataType: expect.stringMatching(/.*char.*\(50\)/), dataType: engine.skipStringLength
? expect.stringMatching(/.*string|char.*/i)
: expect.stringMatching(/.*string|char.*\(50\)/i),
}), }),
...(nextcol ...(nextcol
? [ ? [
expect.objectContaining({ expect.objectContaining({
columnName: 'nextcol', columnName: 'nextcol',
notNull: false, notNull: false,
dataType: expect.stringMatching(/.*char.*\(50\)/), dataType: engine.skipStringLength
? expect.stringMatching(/.*string.*|char.*/i)
: expect.stringMatching(/.*string.*|char.*\(50\).*/i),
}), }),
] ]
: []), : []),
@@ -52,6 +56,9 @@ describe('Table analyse', () => {
const structure = await driver.analyseFull(conn); const structure = await driver.analyseFull(conn);
console.log('****************** TABLE ***********************')
console.log(JSON.stringify(structure.tables[0], null, 2));
expect(structure.tables.length).toEqual(1); expect(structure.tables.length).toEqual(1);
expect(structure.tables[0]).toEqual(t1Match(engine)); expect(structure.tables[0]).toEqual(t1Match(engine));
}) })
@@ -113,7 +120,7 @@ describe('Table analyse', () => {
}) })
); );
test.each(engines.map(engine => [engine.label, engine]))( test.each(engines.filter(x => !x.skipIndexes).map(engine => [engine.label, engine]))(
'Index - full analysis - %s', 'Index - full analysis - %s',
testWrapper(async (conn, driver, engine) => { testWrapper(async (conn, driver, engine) => {
await driver.query(conn, t1Sql); await driver.query(conn, t1Sql);
@@ -128,7 +135,7 @@ describe('Table analyse', () => {
}) })
); );
test.each(engines.map(engine => [engine.label, engine]))( test.each(engines.filter(x => !x.skipUnique).map(engine => [engine.label, engine]))(
'Unique - full analysis - %s', 'Unique - full analysis - %s',
testWrapper(async (conn, driver, engine) => { testWrapper(async (conn, driver, engine) => {
await driver.query(conn, t2Sql); await driver.query(conn, t2Sql);
@@ -142,7 +149,7 @@ describe('Table analyse', () => {
}) })
); );
test.each(engines.map(engine => [engine.label, engine]))( test.each(engines.filter(x => !x.skipReferences).map(engine => [engine.label, engine]))(
'Foreign key - full analysis - %s', 'Foreign key - full analysis - %s',
testWrapper(async (conn, driver, engine) => { testWrapper(async (conn, driver, engine) => {
await driver.query(conn, t2Sql); await driver.query(conn, t2Sql);

View File

@@ -155,13 +155,13 @@ 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',
]; ];
const enginesPostgre = engines.filter(x => x.label == 'PostgreSQL'); const enginesPostgre = engines.filter(x => x.label == 'PostgreSQL');