Skip to content

Commit

Permalink
Test that event listeners are released
Browse files Browse the repository at this point in the history
  • Loading branch information
benjie committed Oct 19, 2023
1 parent 150beee commit 42c2fd3
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions __tests__/main.runTaskList.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ test("main will execute jobs as they come up, and exits cleanly", () =>
};

// Run the worker
expect(process.listeners("SIGTERM")).toHaveLength(0);
const workerPool = runTaskList({ concurrency: 3 }, tasks, pgPool);
expect(process.listeners("SIGTERM")).toHaveLength(1);
let finished = false;
workerPool.promise.then(() => {
finished = true;
Expand All @@ -69,6 +71,7 @@ test("main will execute jobs as they come up, and exits cleanly", () =>
expect(finished).toBeTruthy();
await workerPool.promise;
expect(await jobCount(pgPool)).toEqual(0);
expect(process.listeners("SIGTERM")).toHaveLength(0);
} finally {
Object.values(jobPromises).forEach((p) => p?.resolve());
}
Expand Down

0 comments on commit 42c2fd3

Please sign in to comment.