- Añade ImportRunner en memoria con concurrencia configurable - Tests TDD para enqueue, concurrencia y comportamiento tras stop - Actualiza /api/import/scan para encolar jobs y registrar errores - Ajusta tsconfig.json para incluir tests en comprobaciones de tipo
36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import path from 'path';
|
|
import fs from 'fs';
|
|
import { parseDat, verifyRomAgainstDat } from '../../src/services/datVerifier';
|
|
|
|
const fixturesDir = path.join(__dirname, '..', 'fixtures');
|
|
const datPath = path.join(fixturesDir, 'dats', 'sample-no-intro.dat.xml');
|
|
const simpleRom = path.join(fixturesDir, 'simple-rom.bin');
|
|
|
|
const runIntegration = !!process.env.INTEGRATION;
|
|
const describeIf = runIntegration ? describe : describe.skip;
|
|
|
|
describeIf('services/datVerifier', () => {
|
|
it('parsea DAT xml', () => {
|
|
const xml = fs.readFileSync(datPath, 'utf8');
|
|
const parsed = parseDat(xml);
|
|
expect(parsed).toBeDefined();
|
|
});
|
|
|
|
it('verifica rom contra DAT', async () => {
|
|
const stats = fs.statSync(simpleRom);
|
|
const romMeta = {
|
|
filename: 'simple-rom.bin',
|
|
size: stats.size,
|
|
md5: 'placeholder',
|
|
sha1: 'placeholder',
|
|
crc32: 'placeholder',
|
|
} as any;
|
|
|
|
const xml = fs.readFileSync(datPath, 'utf8');
|
|
const parsed = parseDat(xml);
|
|
const res = await verifyRomAgainstDat(romMeta, parsed);
|
|
expect(res).toBeDefined();
|
|
});
|
|
});
|