mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-23 23:46:35 +00:00
chore(server): lint:boundaries refuses a provider that imports the orchestrator above it
This commit is contained in:
@@ -16,7 +16,15 @@ import { afterEach, describe, expect, it } from 'vitest';
|
||||
|
||||
const SCRIPT = path.join(__dirname, '../../../scripts/import-boundaries.mjs');
|
||||
|
||||
const EMPTY = { fileCycles: [], domainCycles: [], sharedImportsDomain: [], domainInternals: [], dbImportsNest: [], foreignRepositories: [] };
|
||||
const EMPTY = {
|
||||
fileCycles: [],
|
||||
domainCycles: [],
|
||||
sharedImportsDomain: [],
|
||||
domainInternals: [],
|
||||
dbImportsNest: [],
|
||||
foreignRepositories: [],
|
||||
providersImportOrchestrator: [],
|
||||
};
|
||||
|
||||
interface ExecError {
|
||||
status: number | null;
|
||||
@@ -170,6 +178,25 @@ describe('import-boundaries.mjs', () => {
|
||||
expect(out).toContain('FAIL dbImportsNest: db/orm.ts -> nest/database/request-context.ts');
|
||||
});
|
||||
|
||||
it('BOUND-012: a provider may not import the orchestrator above it, type-only included', () => {
|
||||
const dir = serverRoot({
|
||||
'nest/maps/maps.service.ts': "import { Osm } from './providers/osm.client';\nexport class MapsService { o = Osm; }\n",
|
||||
'nest/maps/providers/osm.client.ts': "import type { MapsService } from '../maps.service';\nexport class Osm { m?: MapsService; }\n",
|
||||
'nest/docs/docs.service.ts': 'export class DocsService {}\n',
|
||||
'nest/docs/providers/webdav/client.ts': "import { DocsService } from '../../docs.service';\nexport const c = DocsService;\n",
|
||||
'nest/trips/providers/geo.ts': "import { MapsService } from '../../maps/maps.service';\nexport const g = MapsService;\n",
|
||||
// A provider importing another service of its own domain is not the orchestrator.
|
||||
'nest/docs/docs-cache.service.ts': 'export class DocsCacheService {}\n',
|
||||
'nest/docs/providers/cached.ts': "import { DocsCacheService } from '../docs-cache.service';\nexport const k = DocsCacheService;\n",
|
||||
});
|
||||
const { status, out } = run(dir);
|
||||
expect(status).toBe(1);
|
||||
expect(out).toContain('FAIL providersImportOrchestrator: nest/maps/providers/osm.client.ts -> nest/maps/maps.service.ts');
|
||||
expect(out).toContain('FAIL providersImportOrchestrator: nest/docs/providers/webdav/client.ts -> nest/docs/docs.service.ts');
|
||||
expect(out).toContain('FAIL providersImportOrchestrator: nest/trips/providers/geo.ts -> nest/maps/maps.service.ts');
|
||||
expect(out).not.toContain('providers/cached.ts');
|
||||
});
|
||||
|
||||
it('BOUND-008: a baselined violation passes; a gone one fails and --update drops it without adding', () => {
|
||||
const files = {
|
||||
'nest/b/b.helpers.ts': 'export const h = 1;\n',
|
||||
|
||||
Reference in New Issue
Block a user