From bcac1803a87e7cbb6fcbebd691a322d796266329 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Mon, 8 Jul 2024 14:11:09 +0200 Subject: [PATCH] test: improve WorkerNode init coverage MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- jsr.json | 7 +------ package.json | 4 +--- tests/pools/worker-node.test.mjs | 25 +++++++++++++++++++++++++ 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/jsr.json b/jsr.json index 2e38b0ad..38463ac2 100644 --- a/jsr.json +++ b/jsr.json @@ -4,11 +4,6 @@ "version": "4.0.17", "exports": "./src/index.ts", "publish": { - "include": [ - "LICENSE", - "README.md", - "jsr.json", - "src/**/*.ts" - ] + "include": ["LICENSE", "README.md", "jsr.json", "src/**/*.ts"] } } diff --git a/package.json b/package.json index 414f8ba1..759e56a8 100644 --- a/package.json +++ b/package.json @@ -93,9 +93,7 @@ "url": "https://github.com/poolifier/poolifier/issues" }, "homepage": "https://github.com/poolifier/poolifier#readme", - "files": [ - "lib" - ], + "files": ["lib"], "pnpm": { "overrides": { "semver": "^7.5.3" diff --git a/tests/pools/worker-node.test.mjs b/tests/pools/worker-node.test.mjs index a5411808..886e01bf 100644 --- a/tests/pools/worker-node.test.mjs +++ b/tests/pools/worker-node.test.mjs @@ -5,6 +5,7 @@ import { expect } from 'expect' import { CircularBuffer } from '../../lib/circular-buffer.cjs' import { WorkerTypes } from '../../lib/index.cjs' +import { MeasurementHistorySize } from '../../lib/pools/worker.cjs' import { WorkerNode } from '../../lib/pools/worker-node.cjs' import { PriorityQueue } from '../../lib/queues/priority-queue.cjs' import { DEFAULT_TASK_NAME } from '../../lib/utils.cjs' @@ -258,6 +259,18 @@ describe('Worker node test suite', () => { }, }, }) + expect(threadWorkerNode.usage.runTime.history.items.length).toBe( + MeasurementHistorySize + ) + expect(threadWorkerNode.usage.waitTime.history.items.length).toBe( + MeasurementHistorySize + ) + expect(threadWorkerNode.usage.elu.idle.history.items.length).toBe( + MeasurementHistorySize + ) + expect(threadWorkerNode.usage.elu.active.history.items.length).toBe( + MeasurementHistorySize + ) expect(threadWorkerNode.messageChannel).toBeInstanceOf(MessageChannel) expect(threadWorkerNode.tasksQueueBackPressureSize).toBe(12) expect(threadWorkerNode.tasksQueue).toBeInstanceOf(PriorityQueue) @@ -305,6 +318,18 @@ describe('Worker node test suite', () => { }, }, }) + expect(clusterWorkerNode.usage.runTime.history.items.length).toBe( + MeasurementHistorySize + ) + expect(clusterWorkerNode.usage.waitTime.history.items.length).toBe( + MeasurementHistorySize + ) + expect(clusterWorkerNode.usage.elu.idle.history.items.length).toBe( + MeasurementHistorySize + ) + expect(clusterWorkerNode.usage.elu.active.history.items.length).toBe( + MeasurementHistorySize + ) expect(clusterWorkerNode.messageChannel).toBeUndefined() expect(clusterWorkerNode.tasksQueueBackPressureSize).toBe(12) expect(clusterWorkerNode.tasksQueue).toBeInstanceOf(PriorityQueue) -- 2.34.1