This commit is contained in:
Adria Navarro 2023-05-11 10:58:50 +02:00
parent 25233c5c9b
commit b022dcba77
3 changed files with 4 additions and 8 deletions

View File

@ -121,9 +121,7 @@ export async function getIntegration(integration: SourceName) {
throw new Error("No datasource implementation found.")
}
const VALIDATORS: Partial<
Record<SourceName, (config: any) => Promise<boolean | { error: string }>>
> = {
const VALIDATORS = {
[SourceName.POSTGRES]: postgres.validateConnection,
}
@ -134,5 +132,5 @@ function getValidators(integration: SourceName) {
export default {
getDefinitions,
getIntegration,
getValidators,
getValidator: VALIDATORS,
}

View File

@ -31,7 +31,7 @@ if (types) {
const JSON_REGEX = /'{.*}'::json/s
interface PostgresConfig {
export interface PostgresConfig {
host: string
port: number
database: string

View File

@ -6,7 +6,7 @@ jest.unmock("pg")
describe("datasource validators", () => {
describe("postgres", () => {
const validator = integrations.getValidators(SourceName.POSTGRES)!
const validator = integrations.getValidator[SourceName.POSTGRES]!
let host: string
let port: number
@ -31,7 +31,6 @@ describe("datasource validators", () => {
schema: "public",
ssl: false,
rejectUnauthorized: false,
ca: false,
})
expect(result).toBeTruthy()
})
@ -46,7 +45,6 @@ describe("datasource validators", () => {
schema: "public",
ssl: false,
rejectUnauthorized: false,
ca: false,
})
expect(result).toEqual({
error: 'password authentication failed for user "wrong"',