T-10: M0.3b — Delete legacy MongoDB-writing sync-ib-exchanges operation and its web-api/web-app hooks

This commit is contained in:
Studio 2026-11-27 11:37:04 -05:00
parent 890761e0d5
commit e9659f4dfb
8 changed files with 79 additions and 290 deletions

View file

@ -0,0 +1,79 @@
import { existsSync, readFileSync } from 'node:fs';
import { join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { describe, expect, it } from 'bun:test';
import { Hono } from 'hono';
import type { IServiceContainer } from '@stock-bot/handlers';
import { createPipelineRoutes } from '../../apps/stock/web-api/src/routes/pipeline.routes';
const repository = fileURLToPath(new URL('../../', import.meta.url));
function scanSourceFiles(relativeDir: string): string[] {
const dir = join(repository, relativeDir);
return [...new Bun.Glob('**/*.{ts,tsx}').scanSync({ cwd: dir })].map(file => join(dir, file));
}
describe('legacy sync-ib-exchanges removal', () => {
it('legacy MongoDB-writing sync-ib-exchanges operations file does not exist', () => {
const legacyFile = join(
repository,
'apps/stock/data-pipeline/src/handlers/exchanges/operations/sync-ib-exchanges.operations.ts'
);
expect(existsSync(legacyFile)).toBe(false);
});
it('no source file in data-pipeline, web-api, or web-app references sync-ib-exchanges or syncIBExchanges', () => {
const trees = [
'apps/stock/data-pipeline/src',
'apps/stock/web-api/src',
'apps/stock/web-app/src',
];
const forbiddenSymbols = ['sync-ib-exchanges', 'syncIBExchanges'];
const hits: string[] = [];
for (const tree of trees) {
for (const file of scanSourceFiles(tree)) {
const content = readFileSync(file, 'utf8');
for (const token of forbiddenSymbols) {
if (content.includes(token)) {
hits.push(`${file}: ${token}`);
}
}
if (tree !== 'apps/stock/data-pipeline/src' && content.includes('/provider-mappings/ib')) {
hits.push(`${file}: /provider-mappings/ib`);
}
}
}
expect(hits).toEqual([]);
});
it('POST /api/pipeline/provider-mappings/ib returns 404 without enqueueing jobs while QM mapping route stays active', async () => {
const jobs: unknown[] = [];
const services = {
queueManager: {
getQueue() {
return {
async add(_name: string, data: unknown) {
jobs.push(data);
return { id: 'fixture' };
},
};
},
},
} as unknown as IServiceContainer;
const app = new Hono();
app.route('/api/pipeline', createPipelineRoutes(services));
const removed = await app.request('/api/pipeline/provider-mappings/ib', { method: 'POST' });
expect(removed.status).toBe(404);
expect(jobs).toHaveLength(0);
const active = await app.request('/api/pipeline/provider-mappings/qm', { method: 'POST' });
expect(active.status).toBe(200);
expect(jobs).toEqual([
{ handler: 'exchanges', operation: 'sync-qm-provider-mappings', payload: {} },
]);
});
});