From 322dc2e5a62ced845dfa4c045f3ca1540b795b17 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Tue, 10 Dec 2024 13:33:38 +0000 Subject: [PATCH] Adding legacy postgres option. --- .../server/src/integration-test/postgres.spec.ts | 5 +++-- .../server/src/integrations/tests/utils/images.ts | 1 + .../server/src/integrations/tests/utils/index.ts | 3 +++ .../src/integrations/tests/utils/postgres.ts | 14 +++++++++++--- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/packages/server/src/integration-test/postgres.spec.ts b/packages/server/src/integration-test/postgres.spec.ts index 88250373f8..6e674aa58e 100644 --- a/packages/server/src/integration-test/postgres.spec.ts +++ b/packages/server/src/integration-test/postgres.spec.ts @@ -1,5 +1,4 @@ import { Datasource, FieldType, Table } from "@budibase/types" -import _ from "lodash" import { generator } from "@budibase/backend-core/tests" import { DatabaseName, @@ -8,7 +7,9 @@ import { } from "../integrations/tests/utils" import { Knex } from "knex" -const mainDescriptions = datasourceDescribe({ only: [DatabaseName.POSTGRES] }) +const mainDescriptions = datasourceDescribe({ + only: [DatabaseName.POSTGRES, DatabaseName.POSTGRES_LEGACY], +}) if (mainDescriptions.length) { describe.each(mainDescriptions)( diff --git a/packages/server/src/integrations/tests/utils/images.ts b/packages/server/src/integrations/tests/utils/images.ts index 8c2bb9b220..00686412c6 100644 --- a/packages/server/src/integrations/tests/utils/images.ts +++ b/packages/server/src/integrations/tests/utils/images.ts @@ -9,5 +9,6 @@ dotenv.config({ 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 POSTGRES_LEGACY_IMAGE = `postgres:9.5.25` export const MONGODB_IMAGE = `mongo@${process.env.MONGODB_SHA}` export const MARIADB_IMAGE = `mariadb@${process.env.MARIADB_SHA}` diff --git a/packages/server/src/integrations/tests/utils/index.ts b/packages/server/src/integrations/tests/utils/index.ts index cdf2c4021c..9f443c3988 100644 --- a/packages/server/src/integrations/tests/utils/index.ts +++ b/packages/server/src/integrations/tests/utils/index.ts @@ -9,6 +9,7 @@ import * as oracle from "./oracle" import { testContainerUtils } from "@budibase/backend-core/tests" import { Knex } from "knex" import TestConfiguration from "../../../tests/utilities/TestConfiguration" +import { getLegacyDatasource } from "./postgres" export type DatasourceProvider = () => Promise @@ -16,6 +17,7 @@ export const { startContainer } = testContainerUtils export enum DatabaseName { POSTGRES = "postgres", + POSTGRES_LEGACY = "postgres_legacy", MONGODB = "mongodb", MYSQL = "mysql", SQL_SERVER = "mssql", @@ -26,6 +28,7 @@ export enum DatabaseName { const providers: Record = { [DatabaseName.POSTGRES]: postgres.getDatasource, + [DatabaseName.POSTGRES_LEGACY]: postgres.getLegacyDatasource, [DatabaseName.MONGODB]: mongodb.getDatasource, [DatabaseName.MYSQL]: mysql.getDatasource, [DatabaseName.SQL_SERVER]: mssql.getDatasource, diff --git a/packages/server/src/integrations/tests/utils/postgres.ts b/packages/server/src/integrations/tests/utils/postgres.ts index fc52a724ad..cca127e84f 100644 --- a/packages/server/src/integrations/tests/utils/postgres.ts +++ b/packages/server/src/integrations/tests/utils/postgres.ts @@ -3,14 +3,14 @@ import { GenericContainer, Wait } from "testcontainers" import { generator, testContainerUtils } from "@budibase/backend-core/tests" import { startContainer } from "." import knex, { Knex } from "knex" -import { POSTGRES_IMAGE } from "./images" +import { POSTGRES_IMAGE, POSTGRES_LEGACY_IMAGE } from "./images" let ports: Promise -export async function getDatasource(): Promise { +async function datasourceWithImage(image: string): Promise { if (!ports) { ports = startContainer( - new GenericContainer(POSTGRES_IMAGE) + new GenericContainer(image) .withExposedPorts(5432) .withEnvironment({ POSTGRES_PASSWORD: "password" }) .withWaitStrategy( @@ -51,6 +51,14 @@ export async function getDatasource(): Promise { return datasource } +export async function getDatasource(): Promise { + return datasourceWithImage(POSTGRES_IMAGE) +} + +export async function getLegacyDatasource(): Promise { + return datasourceWithImage(POSTGRES_LEGACY_IMAGE) +} + export async function knexClient( ds: Datasource, opts?: Knex.Config