also looking at this
test(pg): make the Postgres-gated tests actually run in CI
#1077
4 files
+68
-35
| @@ -14,18 +14,10 @@ import { tmpdir } from 'node:os' | ||
| 14 | 14 | import { join, resolve } from 'node:path' |
| 15 | 15 | import { SQL } from 'bun' |
| 16 | 16 | import { describe, expect, it } from 'bun:test' |
| 17 | import { PG_URL, probePostgres } from './pg' | |
| 18 | ||
| 19 | const pgAvailable = await probePostgres() | |
| 17 | 20 | |
| 18 | const PG_URL = `postgres://${process.env.USER}@localhost:5432/postgres` | |
| 19 | let pgAvailable = false | |
| 20 | try { | |
| 21 | const probe = new SQL(PG_URL) | |
| 22 | await probe.unsafe('SELECT 1') | |
| 23 | await probe.end() | |
| 24 | pgAvailable = true | |
| 25 | } | |
| 26 | catch { | |
| 27 | pgAvailable = false | |
| 28 | } | |
| 29 | 21 | |
| 30 | 22 | describe.skipIf(!pgAvailable)('Postgres integration (#1038)', () => { |
| 31 | 23 | it('runs ORM CRUD + relations + raw builder against live Postgres', () => { |
| @@ -47,7 +39,9 @@ await raw.unsafe('CREATE TABLE _qb_users (id serial primary key, name text, age | ||
| 47 | 39 | await raw.unsafe('CREATE TABLE _qb_posts (id serial primary key, title text, pguser_id int)') |
| 48 | 40 | await raw.end() |
| 49 | 41 | |
| 50 | setConfig({ dialect: 'postgres', database: { database: 'postgres', username: process.env.USER, host: 'localhost', port: 5432, password: '' } }) | |
| 42 | // Configure from the same URL the gate probed, not a second hand-built copy of | |
| 43 | // it — the two drifting is what made this file skip in CI. | |
| 44 | setConfig({ dialect: 'postgres', database: { url: URL } }) | |
| 51 | 45 | resetConnection() |
| 52 | 46 | |
| 53 | 47 | // defineModel registers in the model registry, so relations resolve to the |