import { lock, buildLockFilePath } from '../FL2DFW3Y.js';
import { it, globalExpect } from '../XCMLC6HI.js';
import { init_esm_shims } from '../4RNWLMHM.js';
import { mkdir, writeFile, stat } from 'node:fs/promises';
import { dirname } from 'node:path';

// src/core/lock.test.ts
init_esm_shims();
it("runs a callback", async () => {
  await lock("once", async () => null);
});
it("runs a callback twice", async () => {
  await lock("twice", async () => null);
  await lock("twice", async () => null);
});
it("throws an error on timeout", async () => {
  const key = "timeout";
  const path = buildLockFilePath(key);
  await mkdir(dirname(path), {
    recursive: true
  });
  await writeFile(path, "");
  await globalExpect(lock(key, async () => null, {
    timeout: 0
  })).rejects.toThrowError(/timeout/i);
  await globalExpect(stat(path)).rejects.toThrowError(/ENOENT/);
});
//# sourceMappingURL=lock.test.js.map
//# sourceMappingURL=lock.test.js.map