diff --git a/.github/workflows/api-test.yml b/.github/workflows/api-test.yml index 8fd60b54..f9715fda 100644 --- a/.github/workflows/api-test.yml +++ b/.github/workflows/api-test.yml @@ -15,10 +15,11 @@ jobs: postgres: image: postgres:15 ports: - - "5432:5432" + - "5432:5432" env: POSTGRES_USER: kyoo POSTGRES_PASSWORD: password + POSTGRES_DB: kyoo_test options: >- --health-cmd pg_isready --health-interval 10s diff --git a/api/src/db/index.ts b/api/src/db/index.ts index ae67439f..adbe2eb5 100644 --- a/api/src/db/index.ts +++ b/api/src/db/index.ts @@ -112,6 +112,7 @@ const postgresConfig = await parseSslConfig(); // use this when using drizzle-kit since it can't parse await statements // const postgresConfig = config; +console.log("Connecting to postgres with config", postgresConfig); export const db = drizzle({ schema, connection: postgresConfig, diff --git a/api/tests/setup.ts b/api/tests/setup.ts index e9b014f1..75382825 100644 --- a/api/tests/setup.ts +++ b/api/tests/setup.ts @@ -1,9 +1,11 @@ import { beforeAll } from "bun:test"; -import { migrate } from "~/db"; +process.env.PGDATABASE = "kyoo_test"; process.env.JWT_SECRET = "this is a secret"; process.env.JWT_ISSUER = "https://kyoo.zoriya.dev"; beforeAll(async () => { + // lazy load this so env set before actually applies + const { migrate } = await import("~/db"); await migrate(); });