Add pg test container
This commit is contained in:
parent
9bb1a2fa18
commit
7d3c24d257
|
@ -45,3 +45,11 @@ services:
|
||||||
- 6379
|
- 6379
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD", "redis-cli", "ping"]
|
test: ["CMD", "redis-cli", "ping"]
|
||||||
|
|
||||||
|
postgres:
|
||||||
|
image: postgres
|
||||||
|
restart: on-failure
|
||||||
|
ports:
|
||||||
|
- 5432
|
||||||
|
environment:
|
||||||
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
||||||
|
|
|
@ -10,20 +10,29 @@ function getTestContainerSettings(serverName: string, key: string) {
|
||||||
return entry[1]
|
return entry[1]
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCouchConfig() {
|
function getContainerInfo(containerName: string, port: number) {
|
||||||
const port = getTestContainerSettings("COUCHDB-SERVICE", "PORT_5984")
|
const assignedPort = getTestContainerSettings(
|
||||||
|
containerName.toUpperCase(),
|
||||||
|
`PORT_${port}`
|
||||||
|
)
|
||||||
|
const host = getTestContainerSettings(containerName.toUpperCase(), "IP")
|
||||||
return {
|
return {
|
||||||
port,
|
port: assignedPort,
|
||||||
url: `http://${getTestContainerSettings("COUCHDB-SERVICE", "IP")}:${port}`,
|
host,
|
||||||
|
url: `http://${host}:${assignedPort}`,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getMinioConfig() {
|
function getCouchConfig() {
|
||||||
const port = getTestContainerSettings("MINIO-SERVICE", "PORT_9000")
|
return getContainerInfo("couchdb-service", 5984)
|
||||||
return {
|
|
||||||
port,
|
|
||||||
url: `http://${getTestContainerSettings("MINIO-SERVICE", "IP")}:${port}`,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getMinioConfig() {
|
||||||
|
return getContainerInfo("minio-service", 9000)
|
||||||
|
}
|
||||||
|
|
||||||
|
function getPostgresConfig() {
|
||||||
|
return getContainerInfo("postgres", 5432)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setupEnv(...envs: any[]) {
|
export function setupEnv(...envs: any[]) {
|
||||||
|
@ -32,6 +41,8 @@ export function setupEnv(...envs: any[]) {
|
||||||
{ key: "COUCH_DB_URL", value: getCouchConfig().url },
|
{ key: "COUCH_DB_URL", value: getCouchConfig().url },
|
||||||
{ key: "MINIO_PORT", value: getMinioConfig().port },
|
{ key: "MINIO_PORT", value: getMinioConfig().port },
|
||||||
{ key: "MINIO_URL", value: getMinioConfig().url },
|
{ key: "MINIO_URL", value: getMinioConfig().url },
|
||||||
|
{ key: "POSTGRES_HOST", value: getPostgresConfig().host },
|
||||||
|
{ key: "POSTGRES_PORT", value: getPostgresConfig().port },
|
||||||
]
|
]
|
||||||
|
|
||||||
for (const config of configs.filter(x => x.value !== null)) {
|
for (const config of configs.filter(x => x.value !== null)) {
|
||||||
|
|
|
@ -3,6 +3,8 @@ require("dotenv").config({
|
||||||
path: join(__dirname, "..", "..", "hosting", ".env"),
|
path: join(__dirname, "..", "..", "hosting", ".env"),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
process.env.POSTGRES_PASSWORD = "password"
|
||||||
|
|
||||||
const jestTestcontainersConfigGenerator = require("../../jestTestcontainersConfigGenerator")
|
const jestTestcontainersConfigGenerator = require("../../jestTestcontainersConfigGenerator")
|
||||||
|
|
||||||
module.exports = jestTestcontainersConfigGenerator()
|
module.exports = jestTestcontainersConfigGenerator()
|
||||||
|
|
Loading…
Reference in New Issue