forked from MackDing/CodexClaw
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhealthcheck.test.js
More file actions
82 lines (70 loc) · 2.05 KB
/
Copy pathhealthcheck.test.js
File metadata and controls
82 lines (70 loc) · 2.05 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import fs from "node:fs";
import os from "node:os";
import path from "node:path";
import test from "node:test";
import assert from "node:assert/strict";
import { resolveCommandPath, runHealthcheck } from "../src/ops/healthcheck.js";
function createConfig(root) {
return {
app: {
stateFile: path.join(root, ".codex-telegram-claws-state.json")
},
workspace: {
root
},
telegram: {
botToken: "dummy-token"
},
runner: {
command: "node",
cwd: root
},
github: {
defaultWorkdir: root
}
};
}
test("resolveCommandPath finds a binary from PATH", () => {
const resolved = resolveCommandPath("node", process.env);
assert.ok(resolved);
assert.match(resolved, /node$/);
});
test("runHealthcheck passes for a valid local config", async () => {
const root = fs.mkdtempSync(path.join(os.tmpdir(), "claws-health-"));
const config = createConfig(root);
const result = await runHealthcheck(config, {
env: process.env
});
assert.equal(result.ok, true);
assert.equal(
result.checks.some((check) => check.status === "fail"),
false
);
});
test("runHealthcheck warns when the configured command is missing in non-strict mode", async () => {
const root = fs.mkdtempSync(path.join(os.tmpdir(), "claws-health-"));
const config = createConfig(root);
config.runner.command = "definitely-not-a-real-command";
const result = await runHealthcheck(config, {
env: process.env
});
assert.equal(result.ok, true);
assert.equal(
result.checks.some((check) => check.status === "warn"),
true
);
});
test("runHealthcheck fails when the configured command is missing in strict mode", async () => {
const root = fs.mkdtempSync(path.join(os.tmpdir(), "claws-health-"));
const config = createConfig(root);
config.runner.command = "definitely-not-a-real-command";
const result = await runHealthcheck(config, {
env: process.env,
strict: true
});
assert.equal(result.ok, false);
assert.equal(
result.checks.some((check) => check.status === "fail"),
true
);
});