Skip to content

Commit 23b3c18

Browse files
committed
add tests for postgres & mysql drivers
1 parent 544cdc8 commit 23b3c18

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

packages/cubejs-mysql-driver/test/MySqlDriver.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,18 @@ describe('MySqlDriver', () => {
116116
await tableData.release();
117117
}
118118
});
119+
120+
test('table name check', async () => {
121+
const tblName = 'really-really-really-looooooooooooooooooooooooooooooooooooooooooooooooooooong-table-name';
122+
try {
123+
await mySqlDriver.createTable(tblName, [{ name: 'id', type: 'bigint' }]);
124+
125+
throw new Error('createTable must throw an exception');
126+
} catch (e: any) {
127+
expect(e.message).toEqual(
128+
'MySQL can not work with table names longer than 64 symbols. ' +
129+
`Consider using the 'sqlAlias' attribute in your cube definition for ${tblName}.`
130+
);
131+
}
132+
});
119133
});

packages/cubejs-postgres-driver/test/PostgresDriver.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,20 @@ describe('PostgresDriver', () => {
142142
}
143143
});
144144

145+
test('table name check', async () => {
146+
const tblName = 'really-really-really-looooooooooooooooooooooooooooooooooooooooooooooooooooong-table-name';
147+
try {
148+
await driver.createTable(tblName, [{ name: 'id', type: 'bigint' }]);
149+
150+
throw new Error('createTable must throw an exception');
151+
} catch (e: any) {
152+
expect(e.message).toEqual(
153+
'PostgreSQL can not work with table names longer than 63 symbols. ' +
154+
`Consider using the 'sqlAlias' attribute in your cube definition for ${tblName}.`
155+
);
156+
}
157+
});
158+
145159
// Note: This test MUST be the last in the list.
146160
test('release', async () => {
147161
expect(async () => {

0 commit comments

Comments
 (0)