Use docker utils helpers
This commit is contained in:
parent
e4479ee522
commit
baab7d3fb5
|
@ -0,0 +1,5 @@
|
|||
import * as postgres from "./postgres"
|
||||
|
||||
export const testDatasourceConfig = {
|
||||
postgres: postgres.getDatasourceConfig,
|
||||
}
|
|
@ -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,
|
||||
},
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue