diff --git a/tests/acp.test.ts b/tests/acp.test.ts index 7ba32df..59a6c8e 100644 --- a/tests/acp.test.ts +++ b/tests/acp.test.ts @@ -1,8 +1,8 @@ // ACP: the JSON-RPC peer, LLeMbas CLI as an agent (serve --stdio and the LLeMbas link // share it), the device's own limits on remote work, the link itself against a fake LLeMbas, the // service unit, and library: lembas. -import { afterEach, expect, test } from "bun:test" -import { mkdirSync, mkdtempSync, realpathSync, writeFileSync } from "node:fs" +import { afterAll, afterEach, expect, test } from "bun:test" +import { mkdirSync, mkdtempSync, realpathSync, writeFileSync, rmSync } from "node:fs" import { tmpdir } from "node:os" import { join } from "node:path" import { AcpAgent, clampMode, underRoots, type Limits } from "../src/acp/agent.ts" @@ -13,6 +13,13 @@ import { setTrust } from "../src/project/root.ts" import { unitText } from "../src/service.ts" import { delta, fakeProvider, toolCall, type Fake } from "./fake-provider.ts" +// The whole suite shares one config directory: the login this file writes there is taken away +// again, or every later start-up says "not signed in to …" about it. +afterAll(() => { + rmSync(join(paths.config, "lembas.json"), { force: true }) + rmSync(join(paths.config, "lembas"), { recursive: true, force: true }) +}) + let fake: Fake | undefined const stops: (() => void)[] = [] afterEach(() => { diff --git a/tests/lembas-login.test.ts b/tests/lembas-login.test.ts index 1a1a4e4..3e8f731 100644 --- a/tests/lembas-login.test.ts +++ b/tests/lembas-login.test.ts @@ -2,7 +2,7 @@ // discovery document, signed in by device code, one connection named after the instance with the key // in a 0600 file — and the models, their settings, the voice and the search read from the instance // at every start rather than copied into the config. `logout` revokes and removes exactly that. -import { afterEach, beforeEach, expect, test } from "bun:test" +import { afterAll, afterEach, beforeEach, expect, test } from "bun:test" import { existsSync, mkdirSync, readFileSync, rmSync, statSync, writeFileSync } from "node:fs" import { join } from "node:path" import { parse } from "yaml" @@ -17,6 +17,13 @@ import { webuiFetch } from "../src/search/webui.ts" import { wav } from "../src/voice/audio.ts" import { synthesize, transcribe } from "../src/voice/speech.ts" +// The whole suite shares one config directory: the login this file writes there is taken away +// again, or every later start-up says "not signed in to …" about it. +afterAll(() => { + rmSync(join(paths.config, "lembas.json"), { force: true }) + rmSync(join(paths.config, "lembas"), { recursive: true, force: true }) +}) + interface Fake { url: string stop(): void diff --git a/tests/local.test.ts b/tests/local.test.ts index 2eeb408..ceac3a3 100644 --- a/tests/local.test.ts +++ b/tests/local.test.ts @@ -1,7 +1,7 @@ // Local mode (`lembas -l`): everything under the project, the user's login read and nothing more, // and what would reach or be kept on a server turned off. -import { afterEach, expect, test } from "bun:test" -import { existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, realpathSync, writeFileSync } from "node:fs" +import { afterAll, afterEach, expect, test } from "bun:test" +import { existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, realpathSync, writeFileSync, rmSync } from "node:fs" import { tmpdir } from "node:os" import { join } from "node:path" import { addPendingDeleted, pendingDeleted } from "../src/acp/pending.ts" @@ -16,6 +16,13 @@ import { protectedPath } from "../src/permission/hardline.ts" import { enterLocal, LocalError } from "../src/project/local.ts" import { delta, fakeProvider } from "./fake-provider.ts" +// The whole suite shares one config directory: the login this file writes there is taken away +// again, or every later start-up says "not signed in to …" about it. +afterAll(() => { + rmSync(join(globalPaths.config, "lembas.json"), { force: true }) + rmSync(join(globalPaths.config, "lembas"), { recursive: true, force: true }) +}) + const cli = join(import.meta.dir, "../src/cli.ts") const xdgData = process.env.XDG_DATA_HOME