codigo0/backend/node_modules/lazystream/test/fs_test.js
planetazuzu 5d7a6500fe refactor: Fase 1 - Clean Architecture, refactorización modular y eliminación de duplicidades
-  Ticket 1.1: Estructura Clean Architecture en backend
-  Ticket 1.2: Schemas Zod compartidos
-  Ticket 1.3: Refactorización drugs.ts (1362 → 8 archivos modulares)
-  Ticket 1.4: Refactorización procedures.ts (3583 → 6 archivos modulares)
-  Ticket 1.5: Eliminación de duplicidades (~50 líneas)

Cambios principales:
- Creada estructura Clean Architecture en backend/src/
- Schemas Zod compartidos en backend/src/shared/schemas/
- Refactorización modular de drugs y procedures
- Utilidades genéricas en src/utils/ (filter, validation)
- Eliminados scripts obsoletos y documentación antigua
- Corregidos errores: QueryClient, import test-error-handling
- Build verificado y funcionando correctamente
2026-01-25 21:09:47 +01:00

70 lines
1.6 KiB
JavaScript

var stream = require('../lib/lazystream');
var fs = require('fs');
var tmpDir = 'test/tmp/';
var readFile = 'test/data.md';
var writeFile = tmpDir + 'data.md';
exports.fs = {
readwrite: function(test) {
var readfd, writefd;
var readable = new stream.Readable(function() {
return fs.createReadStream(readFile)
.on('open', function(fd) {
readfd = fd;
})
.on('close', function() {
readfd = undefined;
step();
});
});
var writable = new stream.Writable(function() {
return fs.createWriteStream(writeFile)
.on('open', function(fd) {
writefd = fd;
})
.on('close', function() {
writefd = undefined;
step();
});
});
test.expect(3);
test.equal(readfd, undefined, 'Input file should not be opened until read');
test.equal(writefd, undefined, 'Output file should not be opened until write');
if (!fs.existsSync(tmpDir)) {
fs.mkdirSync(tmpDir);
}
if (fs.existsSync(writeFile)) {
fs.unlinkSync(writeFile);
}
readable.on('end', function() { step(); });
writable.on('end', function() { step(); });
var steps = 0;
function step() {
steps += 1;
if (steps == 4) {
var input = fs.readFileSync(readFile);
var output = fs.readFileSync(writeFile);
test.ok(input >= output && input <= output, 'Should be equal');
fs.unlinkSync(writeFile);
fs.rmdirSync(tmpDir);
test.done();
}
};
readable.pipe(writable);
}
};