test: improve WorkerNode init coverage
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Mon, 8 Jul 2024 12:11:09 +0000 (14:11 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Mon, 8 Jul 2024 12:11:09 +0000 (14:11 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
jsr.json
package.json
tests/pools/worker-node.test.mjs

index 2e38b0ad5bcb33c50e547d0fb66050d68e5e65aa..38463ac21535e577d43b257ad5476eb1ca7209de 100644 (file)
--- 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"]
   }
 }
index 414f8ba109c5e97f1315454c51fc07eef4c8b23a..759e56a8e8bb8fa4e93cae0f60bdee6bdd78188c 100644 (file)
@@ -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"
index a541180869cc49c11406c1aed2e0a277d0e938c8..886e01bf2c6fb959e9fb82bedeb2c72486a2be16 100644 (file)
@@ -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)