-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.test.js
More file actions
52 lines (47 loc) · 1.86 KB
/
Copy pathdeploy.test.js
File metadata and controls
52 lines (47 loc) · 1.86 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
import { describe, expect, test } from "bun:test";
import { mkdtempSync, readFileSync, rmSync, statSync } from "fs";
import { tmpdir } from "os";
import { join } from "path";
import { spawnSync } from "child_process";
describe("launchd templates", () => {
test("render portable private plist files", () => {
const root = import.meta.dir;
const temporaryRoot = mkdtempSync(join(tmpdir(), "etwin-launchd-test-"));
const fakeHome = join(temporaryRoot, "home & data");
const destinationDir = join(temporaryRoot, "LaunchAgents & Test");
try {
const result = spawnSync(join(root, "install-launchd.sh"), [], {
cwd: root,
env: {
...process.env,
HOME: fakeHome,
ETWIN_LAUNCHD_DEST_DIR: destinationDir,
},
encoding: "utf-8",
});
expect(result.status).toBe(0);
for (const label of [
"com.etwin-bot",
"com.etwin-codex-bot",
"com.etwin-agy-bot",
]) {
const path = join(destinationDir, `${label}.plist`);
const contents = readFileSync(path, "utf-8");
expect(contents).toContain(root);
expect(contents).toContain(fakeHome.replaceAll("&", "&"));
expect(contents).not.toContain("__ETWIN_ROOT__");
expect(contents).not.toContain("__ETWIN_HOME__");
expect(statSync(path).mode & 0o777).toBe(0o600);
}
const codex = readFileSync(join(destinationDir, "com.etwin-codex-bot.plist"), "utf-8");
expect(codex).toContain("ETWIN_ENV_FILE");
expect(codex).toContain(".env.codex");
const agy = readFileSync(join(destinationDir, "com.etwin-agy-bot.plist"), "utf-8");
expect(agy).toContain("ETWIN_ENV_FILE");
expect(agy).toContain(".env.agy");
expect(agy).toContain("etwin-agy-bot.log");
} finally {
rmSync(temporaryRoot, { recursive: true, force: true });
}
});
});