Add message response
This commit is contained in:
parent
f022a43065
commit
25233c5c9b
|
@ -122,7 +122,7 @@ export async function getIntegration(integration: SourceName) {
|
|||
}
|
||||
|
||||
const VALIDATORS: Partial<
|
||||
Record<SourceName, (config: any) => Promise<boolean>>
|
||||
Record<SourceName, (config: any) => Promise<boolean | { error: string }>>
|
||||
> = {
|
||||
[SourceName.POSTGRES]: postgres.validateConnection,
|
||||
}
|
||||
|
|
|
@ -335,8 +335,8 @@ async function validateConnection(config: PostgresConfig) {
|
|||
try {
|
||||
await integration.openConnection()
|
||||
return true
|
||||
} catch {
|
||||
return false
|
||||
} catch (e: any) {
|
||||
return { error: e.message as string }
|
||||
} finally {
|
||||
await integration.closeConnection()
|
||||
}
|
||||
|
|
|
@ -37,22 +37,20 @@ describe("datasource validators", () => {
|
|||
})
|
||||
|
||||
it("test invalid connection string", async () => {
|
||||
try {
|
||||
const result = await validator({
|
||||
host,
|
||||
port,
|
||||
database: "postgres",
|
||||
user: "wrong",
|
||||
password: "password",
|
||||
schema: "public",
|
||||
ssl: false,
|
||||
rejectUnauthorized: false,
|
||||
ca: false,
|
||||
})
|
||||
expect(result).toBeFalsy()
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
}
|
||||
const result = await validator({
|
||||
host,
|
||||
port,
|
||||
database: "postgres",
|
||||
user: "wrong",
|
||||
password: "password",
|
||||
schema: "public",
|
||||
ssl: false,
|
||||
rejectUnauthorized: false,
|
||||
ca: false,
|
||||
})
|
||||
expect(result).toEqual({
|
||||
error: 'password authentication failed for user "wrong"',
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue