High performance self-hosted photo and video management solution.
TypeScript backup-toolfluttergoogle-photosgoogle-photos-alternativejavascriptmobile-appnestjsnodejsphoto-galleryphotosphotos-managementself-hostedsveltesveltekittypescriptvideos
feat: test for non-standard database name (#19386)
Jason Rasmussen1a90fc8e581e
diff --git a/server/test/medium/globalSetup.ts b/server/test/medium/globalSetup.tsindex 841abfa8b0..811fb2cadb 100644--- a/server/test/medium/globalSetup.ts+++ b/server/test/medium/globalSetup.ts@@ -7,12 +7,13 @@ import { getKyselyConfig } from 'src/utils/database';import { GenericContainer, Wait } from 'testcontainers';const globalSetup = async () => {+ const templateName = 'mich';const postgresContainer = await new GenericContainer('ghcr.io/immich-app/postgres:14-vectorchord0.4.3').withExposedPorts(5432).withEnvironment({POSTGRES_PASSWORD: 'postgres',POSTGRES_USER: 'postgres',- POSTGRES_DB: 'immich',+ POSTGRES_DB: templateName,}).withCommand(['postgres',@@ -35,7 +36,7 @@ const globalSetup = async () => {.start();const postgresPort = postgresContainer.getMappedPort(5432);- const postgresUrl = `postgres://postgres:postgres@localhost:${postgresPort}/immich`;+ const postgresUrl = `postgres://postgres:postgres@localhost:${postgresPort}/${templateName}`;process.env.IMMICH_TEST_POSTGRES_URL = postgresUrl;diff --git a/server/test/utils.ts b/server/test/utils.tsindex 0b3cd186c7..9f3d3f120d 100644--- a/server/test/utils.ts+++ b/server/test/utils.ts@@ -373,18 +373,23 @@ function* newPngFactory() {const pngFactory = newPngFactory();-const withDatabase = (url: string, name: string) => url.replace('/immich', `/${name}`);+const templateName = 'mich';++const withDatabase = (url: string, name: string) => url.replace(`/${templateName}`, `/${name}`);export const getKyselyDB = async (suffix?: string): Promise<Kysely<DB>> => {const testUrl = process.env.IMMICH_TEST_POSTGRES_URL!;const sql = postgres({- ...asPostgresConnectionConfig({ connectionType: 'url', url: withDatabase(testUrl, 'postgres') }),+ ...asPostgresConnectionConfig({+ connectionType: 'url',+ url: withDatabase(testUrl, 'postgres'),+ }),max: 1,});const randomSuffix = Math.random().toString(36).slice(2, 7);const dbName = `immich_${suffix ?? randomSuffix}`;- await sql.unsafe(`CREATE DATABASE ${dbName} WITH TEMPLATE immich OWNER postgres;`);+ await sql.unsafe(`CREATE DATABASE ${dbName} WITH TEMPLATE ${templateName} OWNER postgres;`);return new Kysely<DB>(getKyselyConfig({ connectionType: 'url', url: withDatabase(testUrl, dbName) }));};