chore: code review
Signed-off-by: blam <ben@blam.sh> Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
@@ -163,6 +163,31 @@ describe('postgres', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should throw with incorrect config', async () => {
|
||||
await expect(
|
||||
buildPgDatabaseConfig(
|
||||
new ConfigReader({
|
||||
client: 'pg',
|
||||
connection: {
|
||||
type: 'cloudsql',
|
||||
},
|
||||
}),
|
||||
),
|
||||
).rejects.toThrow(/Missing instance connection name for Cloud SQL/);
|
||||
|
||||
await expect(
|
||||
buildPgDatabaseConfig(
|
||||
new ConfigReader({
|
||||
client: 'not-pg',
|
||||
connection: {
|
||||
type: 'cloudsql',
|
||||
instance: 'asd:asd:asd',
|
||||
},
|
||||
}),
|
||||
),
|
||||
).rejects.toThrow(/Cloud SQL only supports the pg client/);
|
||||
});
|
||||
|
||||
it('adds the settings from cloud-sql-connector', async () => {
|
||||
const { Connector } = jest.requireMock(
|
||||
'@google-cloud/cloud-sql-connector',
|
||||
|
||||
@@ -78,6 +78,10 @@ export async function buildPgDatabaseConfig(
|
||||
);
|
||||
|
||||
if (config.connection?.type === 'cloudsql') {
|
||||
if (config.client !== 'pg') {
|
||||
throw new Error('Cloud SQL only supports the pg client');
|
||||
}
|
||||
|
||||
if (!config.connection.instance) {
|
||||
throw new Error('Missing instance connection name for Cloud SQL');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user