test(session-recovery): avoid shared barrel mock leak
This commit is contained in:
@@ -1,24 +1,5 @@
|
||||
/// <reference types="bun-types" />
|
||||
import { existsSync, rmSync } from "node:fs"
|
||||
import { randomUUID } from "node:crypto"
|
||||
import { tmpdir } from "node:os"
|
||||
import { join } from "node:path"
|
||||
import { afterAll, describe, expect, it, mock } from "bun:test"
|
||||
|
||||
const TEST_STORAGE_ROOT = join(tmpdir(), `session-recovery-latest-thinking-prepend-${randomUUID()}`)
|
||||
const TEST_PART_STORAGE = join(TEST_STORAGE_ROOT, "part")
|
||||
|
||||
mock.module("../../shared", () => ({
|
||||
OPENCODE_STORAGE: TEST_STORAGE_ROOT,
|
||||
MESSAGE_STORAGE: join(TEST_STORAGE_ROOT, "message"),
|
||||
PART_STORAGE: TEST_PART_STORAGE,
|
||||
log: () => {},
|
||||
isSqliteBackend: () => false,
|
||||
patchPart: async () => true,
|
||||
normalizeSDKResponse: <TData>(response: { data?: TData }, fallback: TData) => response.data ?? fallback,
|
||||
}))
|
||||
|
||||
afterAll(() => { mock.restore() })
|
||||
import { describe, expect, it, mock } from "bun:test"
|
||||
|
||||
const { prependThinkingPart, prependThinkingPartAsync } = await import("./storage/thinking-prepend")
|
||||
|
||||
@@ -31,10 +12,6 @@ type StoredPartRecord = {
|
||||
thinking?: string
|
||||
}
|
||||
|
||||
function cleanupParts(messageID: string): void {
|
||||
rmSync(join(TEST_PART_STORAGE, messageID), { recursive: true, force: true })
|
||||
}
|
||||
|
||||
describe("thinking-prepend latest assistant preservation", () => {
|
||||
it("#given file-backed order recovery targets the latest assistant #when prepending thinking #then it refuses to write copied thinking", () => {
|
||||
const sessionID = "ses_latest_file_backed_prepend"
|
||||
@@ -62,8 +39,6 @@ describe("thinking-prepend latest assistant preservation", () => {
|
||||
const result = prependThinkingPart(sessionID, targetMessageID, deps)
|
||||
|
||||
expect(result).toBe(false)
|
||||
expect(existsSync(join(TEST_PART_STORAGE, targetMessageID))).toBe(false)
|
||||
cleanupParts(targetMessageID)
|
||||
})
|
||||
|
||||
it("#given sdk order recovery targets the latest assistant #when prepending thinking #then it refuses to patch copied thinking", async () => {
|
||||
|
||||
Reference in New Issue
Block a user