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