mirror of
https://github.com/OpenRouterTeam/spawn.git
synced 2026-04-28 03:49:31 +00:00
test: remove duplicate corruption recovery test from history.test.ts (#2414)
The "recovers from corrupted existing history file and creates backup" test was a subset of the more thorough coverage in history-corruption.test.ts. Removed the duplicate and its unused readdirSync import. Co-authored-by: spawn-qa-bot <qa@openrouter.ai> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: L <6723574+louisgv@users.noreply.github.com>
This commit is contained in:
parent
f272294902
commit
d60d0626e9
1 changed files with 2 additions and 21 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import type { SpawnRecord } from "../history.js";
|
||||
|
||||
import { afterEach, beforeEach, describe, expect, it } from "bun:test";
|
||||
import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
||||
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
||||
import { homedir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import {
|
||||
|
|
@ -382,26 +382,7 @@ describe("history", () => {
|
|||
expect(data.records[1].agent).toBe("codex");
|
||||
});
|
||||
|
||||
it("recovers from corrupted existing history file and creates backup", () => {
|
||||
writeFileSync(join(testDir, "history.json"), "corrupted{{{");
|
||||
|
||||
saveSpawnRecord({
|
||||
agent: "claude",
|
||||
cloud: "sprite",
|
||||
timestamp: "2026-01-01T00:00:00.000Z",
|
||||
});
|
||||
|
||||
// loadHistory returns [] for corrupted files, so saveSpawnRecord starts fresh
|
||||
const data = JSON.parse(readFileSync(join(testDir, "history.json"), "utf-8"));
|
||||
expect(data.version).toBe(HISTORY_SCHEMA_VERSION);
|
||||
expect(data.records).toHaveLength(1);
|
||||
expect(data.records[0].agent).toBe("claude");
|
||||
|
||||
// Verify .corrupt backup was created
|
||||
const files = readdirSync(testDir);
|
||||
const corruptBackups = files.filter((f) => f.startsWith("history.json.corrupt."));
|
||||
expect(corruptBackups.length).toBeGreaterThanOrEqual(1);
|
||||
});
|
||||
// Corruption recovery and backup tests are in history-corruption.test.ts
|
||||
});
|
||||
|
||||
// ── filterHistory ───────────────────────────────────────────────────────
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue