Skip to content

abso-core

Public

abso is version control for agents: the client, the engine and a server you can run on your own Cloudflare account.

Check passed

Versions 175 to 318

Compare

+60 −0 in 1 place
new file, 60 lines
1+// An init or join that fails against the server leaves the folder as it was, so the same command can run again:
2+// no starting .absoignore or abso.json from init, no .abso/ from join (but a key already here stays).
3+
4+import assert from "node:assert/strict";
5+import { existsSync, mkdirSync, mkdtempSync, readdirSync, rmSync, writeFileSync } from "node:fs";
6+import { tmpdir } from "node:os";
7+import { join } from "node:path";
8+import { after, describe, it } from "node:test";
9+import { main } from "../src/main.ts";
11+// Nothing listens on port 1, so every call fails to connect.
12+const DOWN = "http://127.0.0.1:1";
13+const ENV = { ABSO_TOKEN: "test-token-not-secret", ABSO_SERVERS_FILE: "no-servers.json" };
15+const dirs: string[] = [];
16+after(() => {
17+ for (const d of dirs) rmSync(d, { recursive: true, force: true, maxRetries: 5 });
18+});
20+function temp(): string {
21+ const d = mkdtempSync(join(tmpdir(), "abso-failed-start-"));
22+ dirs.push(d);
23+ return d;
24+}
26+async function run(cwd: string, ...argv: string[]): Promise<number> {
27+ return (await main(argv, { cwd, env: ENV, write: () => {} })).exit;
28+}
30+describe("a failed start", () => {
31+ it("init takes back the .absoignore and abso.json it wrote", async () => {
32+ const dir = temp();
33+ writeFileSync(join(dir, "package.json"), `${JSON.stringify({ scripts: { test: "node --test" } })}\n`);
34+ assert.notEqual(await run(dir, "init", "--server", DOWN, "--project", "p", "--agent", "a"), 0);
35+ assert.deepEqual(readdirSync(dir), ["package.json"]);
36+ });
38+ it("join leaves no .abso folder", async () => {
39+ const dir = temp();
40+ assert.notEqual(await run(dir, "join", "p", "--server", DOWN, "--agent", "a", "--dir", dir), 0);
41+ assert.equal(existsSync(join(dir, ".abso")), false);
42+ });
44+ it("join keeps a key that was already here", async () => {
45+ const dir = temp();
46+ mkdirSync(join(dir, ".abso"));
47+ const key = { server: DOWN, key: "abso_sk_not-a-real-key", id: "k_0123abcd" };
48+ writeFileSync(join(dir, ".abso", "key"), `${JSON.stringify(key)}\n`);
49+ assert.notEqual(await run(dir, "join", "p", "--server", DOWN, "--agent", "a", "--dir", dir), 0);
50+ assert.deepEqual(readdirSync(join(dir, ".abso")), ["key"]);
51+ });
53+ it("join with a key it can't read leaves only that key", async () => {
54+ const dir = temp();
55+ mkdirSync(join(dir, ".abso"));
56+ writeFileSync(join(dir, ".abso", "key"), "{}\n");
57+ assert.notEqual(await run(dir, "join", "p", "--server", DOWN, "--agent", "a", "--dir", dir), 0);
58+ assert.deepEqual(readdirSync(join(dir, ".abso")), ["key"]);
59+ });
60+});
MCP
compare on this site's /mcp
CLI
abso diff 175 318 client/test/failed-start.test.ts --json
JSON
/christopher/abso-core/compare/175..318?file=client%2Ftest%2Ffailed-start.test.ts&format=json