Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions tests/ocl/ocl-background-queue.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const { OCLBackgroundJobQueue } = require('../../tx/ocl/jobs/background-queue');

describe('OCLBackgroundJobQueue', () => {
afterEach(() => {
OCLBackgroundJobQueue.pendingJobs = [];
OCLBackgroundJobQueue.activeCount = 0;
OCLBackgroundJobQueue.queuedOrRunningKeys = new Set();
OCLBackgroundJobQueue.activeJobs = new Map();
OCLBackgroundJobQueue.enqueueSequence = 0;
if (OCLBackgroundJobQueue.heartbeatTimer) {
clearInterval(OCLBackgroundJobQueue.heartbeatTimer);
OCLBackgroundJobQueue.heartbeatTimer = null;
}
});

it('should enqueue a job and mark as queued', () => {
const jobKey = 'job1';
const jobType = 'test-job';
const runJob = jest.fn();
const result = OCLBackgroundJobQueue.enqueue(jobKey, jobType, runJob, { jobSize: 10 });
expect(result).toBe(true);
expect(OCLBackgroundJobQueue.isQueuedOrRunning(jobKey)).toBe(true);
// Não verifica tamanho da fila, pois job pode ser processado imediatamente
});

it('should not enqueue duplicate jobKey', () => {
const jobKey = 'job2';
const runJob = jest.fn();
OCLBackgroundJobQueue.enqueue(jobKey, 'test-job', runJob);
const result = OCLBackgroundJobQueue.enqueue(jobKey, 'test-job', runJob);
expect(result).toBe(false);
});

it('should normalize job size', () => {
expect(OCLBackgroundJobQueue.MAX_CONCURRENT).toBeGreaterThan(0);
expect(OCLBackgroundJobQueue.UNKNOWN_JOB_SIZE).toBe(Number.MAX_SAFE_INTEGER);
});

it('should log heartbeat without error', () => {
OCLBackgroundJobQueue.logHeartbeat();
});
});
192 changes: 0 additions & 192 deletions tests/ocl/ocl-background-resilience.test.js

This file was deleted.

10 changes: 10 additions & 0 deletions tests/ocl/ocl-cache-utils.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const { formatCacheAgeMinutes } = require('../../tx/ocl/cache/cache-utils');

describe('cache-utils', () => {
it('should format cache age in minutes', () => {
expect(formatCacheAgeMinutes(60000)).toBe('1 minute');
expect(formatCacheAgeMinutes(120000)).toBe('2 minutes');
});

// Adicione mais testes para getColdCacheAgeMs e ensureCacheDirectories
});
17 changes: 17 additions & 0 deletions tests/ocl/ocl-cm-provider.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const { OCLConceptMapProvider } = require('../../tx/ocl/cm-ocl');

describe('OCLConceptMapProvider', () => {
it('should instantiate with default config', () => {
const provider = new OCLConceptMapProvider();
expect(provider).toBeTruthy();
});

it('should assign ids', () => {
const provider = new OCLConceptMapProvider();
const ids = new Set();
provider.assignIds(ids);
expect(ids.size).toBeGreaterThanOrEqual(0);
});

// Adicione mais testes para métodos públicos e fluxos de erro
});
Loading
Loading