Skip to content

Commit

Permalink
chore(testing-drivers): arrange tables creation/removal in incrementa…
Browse files Browse the repository at this point in the history
…lSchemaLoading test (#7177)
  • Loading branch information
MikeNitsenko authored Sep 28, 2023
1 parent c5f0b03 commit 5e68c7c
Showing 1 changed file with 21 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export function testIncrementalSchemaLoading(type: string): void {
options: { highWaterMark: number },
) => Promise<any>
};
let query: string[];
let env: Environment;
let inputSchemas: QuerySchemasResult[];
let inputTables: QueryTablesResult[];
Expand All @@ -47,23 +46,35 @@ export function testIncrementalSchemaLoading(type: string): void {
process.env.CUBEJS_DB_PORT = `${env.data.port}`;
}
driver = (await getDriver(type)).source;
const queries = getCreateQueries(type, suffix);
console.log(`Creating ${queries.length} fixture tables`);
try {
for (const q of queries) {
await driver.query(q);
}
console.log(`Creating ${queries.length} fixture tables completed`);
} catch (e: any) {
console.log('Error creating fixtures', e.stack);
throw e;
}
});

afterAll(async () => {
await driver.release();
await env.stop();
try {
console.log(`Dropping ${tables.length} fixture tables`);
for (const t of tables) {
await driver.dropTable(t);
}
console.log(`Dropping ${tables.length} fixture tables completed`);
} finally {
await driver.release();
await env.stop();
}
});

execute('should establish a connection', async () => {
await driver.testConnection();
});

execute('should create the data source', async () => {
query = getCreateQueries(type, suffix);
await Promise.all(query.map(async (q) => {
await driver.query(q);
}));
});

execute('should load and check driver capabilities', async () => {
const capabilities = driver.capabilities();
Expand Down Expand Up @@ -104,13 +115,5 @@ export function testIncrementalSchemaLoading(type: string): void {
data_type: expect.any(String),
});
});

execute('should delete the data source', async () => {
await Promise.all(
tables.map(async (t) => {
await driver.dropTable(t);
})
);
});
});
}

0 comments on commit 5e68c7c

Please sign in to comment.