mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-03 09:38:54 +00:00
test(server): MCP suites run on the booted container and unit suites take services from their module
createTestModule (tests/helpers/test-module.ts) builds a Nest testing module of the domain modules under test over the suite's test db, with a FakeRealtimeService and provider overrides for the collaborators a suite controls. bootTestApp (tests/helpers/test-app.ts) boots AppModule once per file, with recording realtime, fixture storage and an offline geocoder, and the MCP harness takes McpRegistryService from it inside a request context instead of hand-wiring roughly eighty services. The days, day removal and day notes service suites take their subjects from DaysModule and DayNotesModule.
This commit is contained in:
@@ -106,12 +106,21 @@ export async function createTestOrm(
|
||||
// The spread also carries production's `extensions` (Migrator, SeedManager),
|
||||
// `migrations` and `seeder` settings into the harness; only the driver, the
|
||||
// database name, the entity list and discovery noise are overridden.
|
||||
export function createTestMikroOrmModule(db: Database.Database): DynamicModule | Promise<DynamicModule> {
|
||||
//
|
||||
// `allowGlobalContext` is for a unit suite that calls services straight out of
|
||||
// the container (createTestModule): there is no request to fork a context for,
|
||||
// so the repositories read through the global EntityManager, exactly as the
|
||||
// hand-built ones over createTestOrm() do.
|
||||
export function createTestMikroOrmModule(
|
||||
db: Database.Database,
|
||||
options: { allowGlobalContext?: boolean } = {},
|
||||
): DynamicModule | Promise<DynamicModule> {
|
||||
return MikroOrmModule.forRoot({
|
||||
...mikroOrmConfig,
|
||||
entities: [...ALL_ENTITIES],
|
||||
driver: createBoundSqliteDriver(() => db),
|
||||
dbName: ':memory:',
|
||||
discovery: { warnWhenNoEntities: false },
|
||||
...(options.allowGlobalContext ? { allowGlobalContext: true } : {}),
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user