PR comment.

This commit is contained in:
mike12345567 2024-07-24 17:33:39 +01:00
parent b68697002a
commit ea7dffa3d7
6 changed files with 15 additions and 19 deletions

View File

@ -6,12 +6,8 @@ dotenv.config({
path,
})
export function getImageSHAs() {
return {
mssql: `mcr.microsoft.com/mssql/server@${process.env.MSSQL_SHA}`,
mysql: `mysql@${process.env.MYSQL_SHA}`,
postgres: `postgres@${process.env.POSTGRES_SHA}`,
mongodb: `mongo@${process.env.MONGODB_SHA}`,
mariadb: `mariadb@${process.env.MARIADB_SHA}`,
}
}
export const MSSQL_IMAGE = `mcr.microsoft.com/mssql/server@${process.env.MSSQL_SHA}`
export const MYSQL_IMAGE = `mysql@${process.env.MYSQL_SHA}`
export const POSTGRES_IMAGE = `postgres@${process.env.POSTGRES_SHA}`
export const MONGODB_IMAGE = `mongo@${process.env.MONGODB_SHA}`
export const MARIADB_IMAGE = `mariadb@${process.env.MARIADB_SHA}`

View File

@ -4,7 +4,7 @@ import { AbstractWaitStrategy } from "testcontainers/build/wait-strategies/wait-
import { generator, testContainerUtils } from "@budibase/backend-core/tests"
import { startContainer } from "."
import { knexClient } from "./mysql"
import { getImageSHAs } from "./images"
import { MARIADB_IMAGE } from "./images"
let ports: Promise<testContainerUtils.Port[]>
@ -28,7 +28,7 @@ class MariaDBWaitStrategy extends AbstractWaitStrategy {
export async function getDatasource(): Promise<Datasource> {
if (!ports) {
ports = startContainer(
new GenericContainer(getImageSHAs().mariadb)
new GenericContainer(MARIADB_IMAGE)
.withExposedPorts(3306)
.withEnvironment({ MARIADB_ROOT_PASSWORD: "password" })
.withWaitStrategy(new MariaDBWaitStrategy())

View File

@ -2,14 +2,14 @@ import { generator, testContainerUtils } from "@budibase/backend-core/tests"
import { Datasource, SourceName } from "@budibase/types"
import { GenericContainer, Wait } from "testcontainers"
import { startContainer } from "."
import { getImageSHAs } from "./images"
import { MONGODB_IMAGE } from "./images"
let ports: Promise<testContainerUtils.Port[]>
export async function getDatasource(): Promise<Datasource> {
if (!ports) {
ports = startContainer(
new GenericContainer(getImageSHAs().mongodb)
new GenericContainer(MONGODB_IMAGE)
.withExposedPorts(27017)
.withEnvironment({
MONGO_INITDB_ROOT_USERNAME: "mongo",

View File

@ -3,14 +3,14 @@ import { GenericContainer, Wait } from "testcontainers"
import { generator, testContainerUtils } from "@budibase/backend-core/tests"
import { startContainer } from "."
import knex from "knex"
import { getImageSHAs } from "./images"
import { MSSQL_IMAGE } from "./images"
let ports: Promise<testContainerUtils.Port[]>
export async function getDatasource(): Promise<Datasource> {
if (!ports) {
ports = startContainer(
new GenericContainer(getImageSHAs().mssql)
new GenericContainer(MSSQL_IMAGE)
.withExposedPorts(1433)
.withEnvironment({
ACCEPT_EULA: "Y",

View File

@ -4,7 +4,7 @@ import { AbstractWaitStrategy } from "testcontainers/build/wait-strategies/wait-
import { generator, testContainerUtils } from "@budibase/backend-core/tests"
import { startContainer } from "."
import knex from "knex"
import { getImageSHAs } from "./images"
import { MYSQL_IMAGE } from "./images"
let ports: Promise<testContainerUtils.Port[]>
@ -31,7 +31,7 @@ class MySQLWaitStrategy extends AbstractWaitStrategy {
export async function getDatasource(): Promise<Datasource> {
if (!ports) {
ports = startContainer(
new GenericContainer(getImageSHAs().mysql)
new GenericContainer(MYSQL_IMAGE)
.withExposedPorts(3306)
.withEnvironment({ MYSQL_ROOT_PASSWORD: "password" })
.withWaitStrategy(new MySQLWaitStrategy().withStartupTimeout(10000))

View File

@ -3,14 +3,14 @@ import { GenericContainer, Wait } from "testcontainers"
import { generator, testContainerUtils } from "@budibase/backend-core/tests"
import { startContainer } from "."
import knex from "knex"
import { getImageSHAs } from "./images"
import { POSTGRES_IMAGE } from "./images"
let ports: Promise<testContainerUtils.Port[]>
export async function getDatasource(): Promise<Datasource> {
if (!ports) {
ports = startContainer(
new GenericContainer(getImageSHAs().postgres)
new GenericContainer(POSTGRES_IMAGE)
.withExposedPorts(5432)
.withEnvironment({ POSTGRES_PASSWORD: "password" })
.withWaitStrategy(