import test from 'node:test'; import assert from 'node:assert/strict'; import { readdirSync, readFileSync } from 'node:fs'; import path from 'node:path'; import { parseDocument } from 'yaml'; import { CHECKS } from '../src/audit.ts'; const fixtures = path.join(import.meta.dirname, 'fixtures'); function idsIn(directory) { return readdirSync(directory) .filter((name) => name.endsWith('.yaml')) .map((name) => parseDocument(readFileSync(path.join(directory, name), 'utf8')).toJS()?.id); } // The shipped audit engine must not know identifiers of somebody else's fixtures (D-055): // a binding is allowed only for a requirement the product owns — either a requirement of // its own synthetic fixture or a normative requirement pinned as a byte copy in the tree. const owned = new Set([ ...idsIn(path.join(fixtures, 'synthetic-spec', 'requirements')), ...idsIn(path.join(fixtures, 'normative')), ]); test('реестр детерминированных проверок содержит только собственные идентификаторы продукта', () => { const foreign = Object.keys(CHECKS).filter((id) => !owned.has(id)); assert.deepEqual(foreign, [], 'чужие идентификаторы требований в поставляемом реестре'); }); test('охраняющий тест не удовлетворяется пустым реестром', () => { assert.ok(Object.keys(CHECKS).length > 0, 'реестр непустой'); assert.ok( Object.hasOwn(CHECKS, 'req-single-quality-command'), 'закреплённое нормативное требование проверяется детерминированно', ); });