test) stabilize vitest db bootstrap in ci
Some checks failed
PR Checks / lint-test-and-docker-build (pull_request) Failing after 1m10s
Some checks failed
PR Checks / lint-test-and-docker-build (pull_request) Failing after 1m10s
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user