mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-20 11:06:06 +00:00
feat(db): run TREK on PostgreSQL
TREK runs on PostgreSQL when TREK_DB_URL is set, and on SQLite as before otherwise: an engine port under src/db/engine, the dialect helpers under src/db/dialect, a Postgres baseline for the migrations up to the cut, pg_dump/pg_restore backups, a probe of every repository method against a real server and a Postgres test lane in CI.
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* DatabaseEngineModule: one engine per container, shared by every injector.
|
||||
*/
|
||||
import {
|
||||
DatabaseEngineModule,
|
||||
DATABASE_ENGINE,
|
||||
DATABASE_SETTINGS,
|
||||
} from '../../../../src/nest/database/database-engine.module';
|
||||
import { Test } from '@nestjs/testing';
|
||||
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
describe('DatabaseEngineModule', () => {
|
||||
it('ENGINE-DI-001: provides one engine instance, so state an engine keeps is the same wherever it is injected', async () => {
|
||||
const moduleRef = await Test.createTestingModule({ imports: [DatabaseEngineModule] }).compile();
|
||||
|
||||
const engine = moduleRef.get(DATABASE_ENGINE);
|
||||
expect(moduleRef.get(DATABASE_ENGINE)).toBe(engine);
|
||||
expect(engine.id).toBe('sqlite');
|
||||
});
|
||||
|
||||
it('ENGINE-DI-002: the settings are read from the environment once and the engine is resolved from them', async () => {
|
||||
const moduleRef = await Test.createTestingModule({ imports: [DatabaseEngineModule] }).compile();
|
||||
|
||||
const settings = moduleRef.get(DATABASE_SETTINGS);
|
||||
expect(settings.engine).toBe('sqlite');
|
||||
expect(moduleRef.get(DATABASE_SETTINGS)).toBe(settings);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user