From: Jérôme Benoit Date: Mon, 8 Jul 2024 12:11:09 +0000 (+0200) Subject: test: improve WorkerNode init coverage X-Git-Tag: v4.0.18~8 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=bcac1803a87e7cbb6fcbebd691a322d796266329;p=poolifier.git test: improve WorkerNode init coverage Signed-off-by: Jérôme Benoit --- 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)