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

View File

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

View File

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