test) stabilize vitest db bootstrap in ci
Some checks failed
PR Checks / lint-test-and-docker-build (pull_request) Failing after 1m10s

This commit is contained in:
2026-02-20 23:21:41 -05:00
parent e28741a4f1
commit e5c4cbc331
2 changed files with 9 additions and 5 deletions

View File

@@ -35,7 +35,7 @@ jobs:
run: bun run lint
- name: Unit tests
run: bun run test
run: bunx --bun svelte-kit sync && bunx --bun vitest run --maxWorkers=1
- name: Build app
run: bun run build

View File

@@ -3,10 +3,12 @@ import { createSqliteDb } from './sqlite.js';
import { runMigrations } from './migrations.js';
import type { Database } from './types.js';
function createDb(): Database {
const url = env.DATABASE_URL ?? 'file:trips.db';
const isVitest = process.env.VITEST === 'true';
if (url.startsWith('file:') || url.endsWith('.db')) {
function createDb(): Database {
const url = isVitest ? ':memory:' : (env.DATABASE_URL ?? 'file:trips.db');
if (url === ':memory:' || url.startsWith('file:') || url.endsWith('.db')) {
return createSqliteDb(url);
}
@@ -17,7 +19,9 @@ function createDb(): Database {
export let db: Database = createDb();
runMigrations(db);
if (!isVitest) {
runMigrations(db);
}
/**
* Replace the database singleton. For use in tests only — call this with an