fakePool

tcmts.cli.budget.test.fakePool · #jmdjiwuj · term · runs anywhere

A pool whose takes wait until given, and look (call their onWait) when the test says.

import type { SlotPool, SlotWait } from "#codebase/tcmts/cli/budget";

export const fakePool = () => {
  const takes: { onWait: (w: SlotWait) => void; give: () => void }[] = [];
  const pool: SlotPool = {
    size: 3,
    take: (_what, onWait, _count) =>
      new Promise((resolve) => takes.push({ onWait: onWait!, give: () => resolve(() => {}) })),
  };
  return { pool, takes };
}

uses

used by