1
0
Fork 0
mirror of synced 2024-09-08 21:51:58 +12:00

Use docker utils helpers

This commit is contained in:
Adria Navarro 2023-09-04 19:05:11 +02:00
parent e4479ee522
commit baab7d3fb5
2 changed files with 39 additions and 0 deletions

View file

@ -0,0 +1,5 @@
import * as postgres from "./postgres"
export const testDatasourceConfig = {
postgres: postgres.getDatasourceConfig,
}

View file

@ -0,0 +1,34 @@
import { Datasource, SourceName } from "@budibase/types"
import { GenericContainer, Wait } from "testcontainers"
export async function getDatasourceConfig(): Promise<Datasource> {
const containerPostgres = await new GenericContainer("postgres")
.withExposedPorts(5432)
.withEnv("POSTGRES_PASSWORD", "password")
.withWaitStrategy(
Wait.forLogMessage(
"PostgreSQL init process complete; ready for start up."
)
)
.start()
const host = containerPostgres.getContainerIpAddress()
const port = containerPostgres.getMappedPort(5432)
return {
type: "datasource_plus",
source: SourceName.POSTGRES,
plus: true,
config: {
host,
port,
database: "postgres",
user: "postgres",
password: "password",
schema: "public",
ssl: false,
rejectUnauthorized: false,
ca: false,
},
}
}