Skip to content

Commit b0352d2

Browse files
test: leave state/ as it was after a test run
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
1 parent f9e3628 commit b0352d2

3 files changed

Lines changed: 19 additions & 4 deletions

File tree

‎tests/drift.test.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import assert from "node:assert/strict";
2+
import { dirname } from "node:path";
23
import test from "node:test";
34
import {
45
checkPronunciationDictDrop,
@@ -112,7 +113,11 @@ function driftState(
112113
// no real checkout uses, and remove the whole folder when the file finishes.
113114
const HASH_STORE_TEST_ENV = `drift-test-${process.pid}`;
114115
after(() => {
115-
rmSync(hashStoreDir(HASH_STORE_TEST_ENV), { recursive: true, force: true });
116+
// state/<org>/local/baselines → state/<org>
117+
rmSync(dirname(dirname(hashStoreDir(HASH_STORE_TEST_ENV))), {
118+
recursive: true,
119+
force: true,
120+
});
116121
});
117122

118123
test("checkPronunciationDictDrop: warns when prior had ID and new lost it", () => {

‎tests/state-layout.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ test("two state files that disagree stop the command with both intact", () => {
397397

398398
// ── npm run migrate and the legacy-format guard ──────────────────────────
399399

400-
const FAT_STATE = `${JSON.stringify({ assistants: { intake: { uuid: UUID, lastPulledHash: "h" } } })}\n`;
400+
const FAT_STATE = `${JSON.stringify({ assistants: { intake: { uuid: UUID, lastPulledAt: "2026-01-01T00:00:00Z" } } })}\n`;
401401

402402
test("the legacy-format guard reads the state file in either place", () => {
403403
const root = mkdtempSync(join(tmpdir(), "state-layout-"));

‎tests/tool-assistant-cycle.test.ts‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import assert from "node:assert/strict";
2+
import { rmSync } from "node:fs";
3+
import { dirname } from "node:path";
24
import test, { after } from "node:test";
35

46
// ─────────────────────────────────────────────────────────────────────────────
@@ -26,15 +28,23 @@ const {
2628
updateToolAssistantRefs,
2729
} = await import("../src/push.ts");
2830

29-
import { deleteBaseline } from "../src/hash-store.ts";
31+
import { deleteBaseline, hashStoreDir } from "../src/hash-store.ts";
3032
import type { ResourceFile, StateFile } from "../src/types.ts";
3133

3234
const UUID = "8f14e45f-ceea-467a-9f1b-1a1b2c3d4e5f";
3335

3436
// updateToolAssistantRefs records a drift baseline for every PATCH it sends, and
3537
// the hash store resolves beside src/ — not under a temp dir — so remove the
3638
// one these tests write rather than leave it in the developer's real store.
37-
after(() => deleteBaseline("test-fixture-org", UUID));
39+
// The push under test records a baseline in this checkout's state/ folder.
40+
// Remove it and the folders it created, so a test run leaves state/ as it was.
41+
after(async () => {
42+
await deleteBaseline("test-fixture-org", UUID);
43+
rmSync(dirname(dirname(hashStoreDir("test-fixture-org"))), {
44+
recursive: true,
45+
force: true,
46+
});
47+
});
3848

3949
test("an unresolved assistant destination drops the whole destinations key", async () => {
4050
// Unresolved = resolution left the slug exactly as written, because the

0 commit comments

Comments
 (0)