test: make unsafe test coercion explicit

Move test coercion out of a hidden global and require each test to import the helper so review tools and runtime scripts can see the unsafe boundary.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
YeonGyu-Kim
2026-05-12 15:38:31 +09:00
parent ce5da13fc5
commit d5fbada13d
103 changed files with 700 additions and 554 deletions
+6 -5
View File
@@ -3,6 +3,7 @@ import { mkdirSync, writeFileSync, rmSync, existsSync, readdirSync } from "node:
import { join } from "node:path"
import { tmpdir } from "node:os"
import { randomUUID } from "node:crypto"
import { unsafeTestValue } from "../../../test-support/unsafe-test-value"
const TEST_DIR = join(tmpdir(), `omo-test-session-manager-${randomUUID()}`)
const TEST_MESSAGE_STORAGE = join(TEST_DIR, "message")
@@ -448,7 +449,7 @@ describe("session-manager storage - SDK path (beta mode)", () => {
// Re-import to get fresh module with mocked isSqliteBackend
const { setStorageClient, getMainSessions } = await import("./storage")
setStorageClient(testCoerce<Parameters<typeof setStorageClient>[0]>(mockClient))
setStorageClient(unsafeTestValue<Parameters<typeof setStorageClient>[0]>(mockClient))
// when
const sessions = await getMainSessions({ directory: "/test" })
@@ -473,7 +474,7 @@ describe("session-manager storage - SDK path (beta mode)", () => {
}))
const { setStorageClient, getAllSessions } = await import("./storage")
setStorageClient(testCoerce<Parameters<typeof setStorageClient>[0]>(mockClient))
setStorageClient(unsafeTestValue<Parameters<typeof setStorageClient>[0]>(mockClient))
// when
const sessionIDs = await getAllSessions()
@@ -503,7 +504,7 @@ describe("session-manager storage - SDK path (beta mode)", () => {
}))
const { setStorageClient, readSessionMessages } = await import("./storage")
setStorageClient(testCoerce<Parameters<typeof setStorageClient>[0]>(mockClient))
setStorageClient(unsafeTestValue<Parameters<typeof setStorageClient>[0]>(mockClient))
// when
const messages = await readSessionMessages("ses_test")
@@ -531,7 +532,7 @@ describe("session-manager storage - SDK path (beta mode)", () => {
}))
const { setStorageClient, readSessionTodos } = await import("./storage")
setStorageClient(testCoerce<Parameters<typeof setStorageClient>[0]>(mockClient))
setStorageClient(unsafeTestValue<Parameters<typeof setStorageClient>[0]>(mockClient))
// when
const todos = await readSessionTodos("ses_test")
@@ -555,7 +556,7 @@ describe("session-manager storage - SDK path (beta mode)", () => {
}))
const { setStorageClient, readSessionMessages } = await import("./storage")
setStorageClient(testCoerce<Parameters<typeof setStorageClient>[0]>(mockClient))
setStorageClient(unsafeTestValue<Parameters<typeof setStorageClient>[0]>(mockClient))
await expect(readSessionMessages("ses_test")).rejects.toThrow("API error")
})