Skip to content

Commit

Permalink
add tests for postgres & mysql drivers
Browse files Browse the repository at this point in the history
  • Loading branch information
KSDaemon committed Jan 21, 2025
1 parent 544cdc8 commit 23b3c18
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/cubejs-mysql-driver/test/MySqlDriver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,18 @@ describe('MySqlDriver', () => {
await tableData.release();
}
});

test('table name check', async () => {
const tblName = 'really-really-really-looooooooooooooooooooooooooooooooooooooooooooooooooooong-table-name';
try {
await mySqlDriver.createTable(tblName, [{ name: 'id', type: 'bigint' }]);

throw new Error('createTable must throw an exception');
} catch (e: any) {
expect(e.message).toEqual(
'MySQL can not work with table names longer than 64 symbols. ' +
`Consider using the 'sqlAlias' attribute in your cube definition for ${tblName}.`
);
}
});
});
14 changes: 14 additions & 0 deletions packages/cubejs-postgres-driver/test/PostgresDriver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,20 @@ describe('PostgresDriver', () => {
}
});

test('table name check', async () => {
const tblName = 'really-really-really-looooooooooooooooooooooooooooooooooooooooooooooooooooong-table-name';
try {
await driver.createTable(tblName, [{ name: 'id', type: 'bigint' }]);

throw new Error('createTable must throw an exception');
} catch (e: any) {
expect(e.message).toEqual(
'PostgreSQL can not work with table names longer than 63 symbols. ' +
`Consider using the 'sqlAlias' attribute in your cube definition for ${tblName}.`
);
}
});

// Note: This test MUST be the last in the list.
test('release', async () => {
expect(async () => {
Expand Down

0 comments on commit 23b3c18

Please sign in to comment.