feat: stream hashing and archive-entry import support
- Añade `computeHashesFromStream` para hashing desde streams - Adapta `importDirectory` para procesar entradas internas usando `streamArchiveEntry` - Añade tests unitarios para hashing por stream e import de entradas de archive
This commit is contained in:
24
backend/tests/services/checksumService.stream.spec.ts
Normal file
24
backend/tests/services/checksumService.stream.spec.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { Readable } from 'stream';
|
||||
import fs from 'fs/promises';
|
||||
import path from 'path';
|
||||
|
||||
import { computeHashes, computeHashesFromStream } from '../../src/services/checksumService';
|
||||
|
||||
describe('services/checksumService (stream)', () => {
|
||||
it('computeHashesFromStream produces same result as computeHashes(file)', async () => {
|
||||
const data = Buffer.from('quasar-stream-test');
|
||||
const tmpDir = await fs.mkdtemp(path.join(process.cwd(), 'tmp-checksum-'));
|
||||
const tmpFile = path.join(tmpDir, 'test.bin');
|
||||
await fs.writeFile(tmpFile, data);
|
||||
|
||||
const expected = await computeHashes(tmpFile);
|
||||
|
||||
const rs = Readable.from([data]);
|
||||
const actual = await computeHashesFromStream(rs as any);
|
||||
|
||||
expect(actual).toEqual(expected);
|
||||
|
||||
await fs.rm(tmpDir, { recursive: true, force: true });
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user