CARD-07 replaces the linear HTTP matcher with a radix index. Before any of that code changes, the behaviour it must preserve has to exist somewhere the new code cannot quietly move it. manifest.json names the existing tests retained unchanged (ROUTER-CORPUS §1), pinned toed47836instead of42376c6: #117 and #122 landed after the corpus was written. Every named file and test was verified to exist and pass there; none was renamed. Three upgrade-path tests from #117 are listed separately as proposed additions, pending D5. manifest.test.ts fails if a named test disappears. oracle.ts is a verbatim copy of the matcher ated47836(matchRoute, resolveRoute, allowedMethods, normalizeRequestPath, compilePattern, matchWsRoute), with local route types and its own caches. Its header says it must not be edited to fit a new implementation, and the manifest test fails if anything under src/ imports it. frozen.ts reads the captured baseline. It refuses `vitest -u`, and the capture switch only fills a missing file, never overwrites one. Refs #109 Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
60 lines
2.3 KiB
TypeScript
60 lines
2.3 KiB
TypeScript
/**
|
|
* Keeps the retained-test manifest honest: every file it names must exist and every test it names
|
|
* must still be declared there. A rename or deletion during CARD-07 fails here instead of silently
|
|
* shrinking the compatibility baseline. Whether those tests *pass* is `npm test` and the runtime
|
|
* suites' job; this only proves they are still the tests the manifest says they are.
|
|
*/
|
|
import { existsSync, readFileSync, readdirSync } from 'fs';
|
|
import { join } from 'path';
|
|
import { describe, it, expect } from 'vitest';
|
|
import { PINNED_REVISION } from './frozen';
|
|
|
|
interface Entry {
|
|
file: string;
|
|
scope?: 'file' | 'tests';
|
|
tests?: string[];
|
|
}
|
|
|
|
const ROOT = join(__dirname, '..', '..');
|
|
const manifest = JSON.parse(readFileSync(join(__dirname, 'manifest.json'), 'utf8')) as {
|
|
revision: string;
|
|
retained: Entry[];
|
|
runtimeSmoke: Entry[];
|
|
supplementary: { retained: Entry[] };
|
|
frozenFixtures: { oracle: string; readme: string };
|
|
};
|
|
|
|
const entries: Entry[] = [...manifest.retained, ...manifest.runtimeSmoke, ...manifest.supplementary.retained];
|
|
|
|
describe('router parity: retained-test manifest', () => {
|
|
it('is pinned to the same revision as the frozen fixtures', () => {
|
|
expect(manifest.revision).toBe(PINNED_REVISION);
|
|
});
|
|
|
|
for (const entry of entries) {
|
|
it(`${entry.file} exists and declares every named test`, () => {
|
|
const path = join(ROOT, entry.file);
|
|
expect(existsSync(path), `${entry.file} is missing`).toBe(true);
|
|
const source = readFileSync(path, 'utf8');
|
|
|
|
for (const name of entry.tests ?? []) {
|
|
for (const part of name.split(' > ')) expect(source, `${entry.file}: '${name}'`).toContain(part);
|
|
}
|
|
});
|
|
}
|
|
|
|
it('names an oracle and a README that exist', () => {
|
|
for (const file of [manifest.frozenFixtures.oracle, manifest.frozenFixtures.readme])
|
|
expect(existsSync(join(ROOT, file)), file).toBe(true);
|
|
});
|
|
|
|
it('the oracle is not imported from src/', () => {
|
|
// A frozen oracle the product can reach is no longer frozen: someone will "fix" it.
|
|
const files = readdirSync(join(ROOT, 'src'), { recursive: true, encoding: 'utf8' }).filter((f) =>
|
|
f.endsWith('.ts'),
|
|
);
|
|
const hits = files.filter((f) => readFileSync(join(ROOT, 'src', f), 'utf8').includes('router-parity'));
|
|
expect(hits).toEqual([]);
|
|
});
|
|
});
|