Skip to content

Commit c198a8e

Browse files
author
Test
committed
Fix race
1 parent b786b1f commit c198a8e

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

src/vendors/express/express-server.generator.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,8 @@ export function createMcpRouter() {
298298
}
299299
300300
// 3. Resolve DAOs
301-
const factory = new DaoFactory();
301+
app.locals.dataSource = dataSource;
302+
const factory = new DaoFactory();
302303
303304
// In a full DI implementation, the DAO factory would be passed to routers or services.
304305
// For now, we pass dataSource directly to the generated TypeORM routes if it exists,
@@ -357,16 +358,19 @@ export function createMcpRouter() {
357358
it('should initialize stub mode when no DB args are provided', async () => {
358359
const app = await startServer(['node', 'script.js']);
359360
expect(app).toBeDefined();
361+
if ((app as any).locals && (app as any).locals.dataSource) await (app as any).locals.dataSource.destroy();
360362
});
361363
362364
it('should initialize ephemeral mode with --ephemeral', async () => {
363365
const app = await startServer(['node', 'script.js', '--ephemeral']);
364366
expect(app).toBeDefined();
367+
if ((app as any).locals && (app as any).locals.dataSource) await (app as any).locals.dataSource.destroy();
365368
});
366369
367370
it('should seed data when --seed and --ephemeral are provided', async () => {
368371
const app = await startServer(['node', 'script.js', '--ephemeral', '--seed']);
369372
expect(app).toBeDefined();
373+
if ((app as any).locals && (app as any).locals.dataSource) await (app as any).locals.dataSource.destroy();
370374
});
371375
});
372376
`);

src/vendors/typeorm/tests.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ describe('Mock Server Integration Tests', () => {
5454
// No args = Stub mode
5555
app = await startServer(['node', 'script.js']);
5656
});
57+
afterAll(async () => {
58+
if (app && app.locals && app.locals.dataSource) {
59+
await app.locals.dataSource.destroy();
60+
}
61+
});
5762
5863
${schemas
5964
.map(
@@ -73,6 +78,11 @@ describe('Mock Server Integration Tests', () => {
7378
beforeAll(async () => {
7479
app = await startServer(['node', 'script.js', '--ephemeral']);
7580
});
81+
afterAll(async () => {
82+
if (app && app.locals && app.locals.dataSource) {
83+
await app.locals.dataSource.destroy();
84+
}
85+
});
7686
7787
${schemas
7888
.map(
@@ -96,6 +106,11 @@ describe('Mock Server Integration Tests', () => {
96106
beforeAll(async () => {
97107
app = await startServer(['node', 'script.js', '--ephemeral', '--seed']);
98108
});
109+
afterAll(async () => {
110+
if (app && app.locals && app.locals.dataSource) {
111+
await app.locals.dataSource.destroy();
112+
}
113+
});
99114
100115
${schemas
101116
.map(

0 commit comments

Comments
 (0)