2026-05-20 21:39:12 +08:00

18 lines
618 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import * as fs from 'node:fs';
import * as os from 'node:os';
import * as path from 'node:path';
import { acquireRuntimeLock, readRuntimeLock, releaseRuntimeLock } from '../../src/comm/runtime-lock';
describe('runtime lock', () => {
it('写入当前 pid并在释放时删除锁文件', () => {
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'neta-lock-'));
const lockPath = path.join(tempDir, 'neta.lock');
acquireRuntimeLock(lockPath);
expect(readRuntimeLock(lockPath).pid).toBe(process.pid);
releaseRuntimeLock(lockPath);
expect(fs.existsSync(lockPath)).toBe(false);
});
});