-
Notifications
You must be signed in to change notification settings - Fork 131
Expand file tree
/
Copy pathprocess-identity.test.ts
More file actions
41 lines (37 loc) · 1.23 KB
/
process-identity.test.ts
File metadata and controls
41 lines (37 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { test } from 'vitest';
import assert from 'node:assert/strict';
import {
isAgentDeviceDaemonCommand,
isProcessAlive,
isProcessGroupAlive,
readProcessStartTime,
readProcessCommand,
} from '../process-identity.ts';
test('isProcessAlive returns false for invalid pid', () => {
assert.equal(isProcessAlive(-1), false);
});
test('isProcessGroupAlive returns false for invalid pid', () => {
assert.equal(isProcessGroupAlive(-1), false);
});
test('readProcessStartTime returns value for current process', () => {
const startTime = readProcessStartTime(process.pid);
if (startTime === null) {
assert.equal(readProcessCommand(process.pid), null);
return;
}
assert.ok(startTime.length > 0);
});
test('isAgentDeviceDaemonCommand matches expected daemon command', () => {
assert.equal(isAgentDeviceDaemonCommand('node /tmp/agent-device/dist/src/daemon.js'), true);
assert.equal(
isAgentDeviceDaemonCommand('node /tmp/agent-device/dist/src/internal/daemon.js'),
true,
);
assert.equal(
isAgentDeviceDaemonCommand(
'node --experimental-strip-types /worktrees/agent-device/src/daemon.ts',
),
true,
);
assert.equal(isAgentDeviceDaemonCommand('node -e "setInterval(() => {}, 1000)"'), false);
});