fix(test): mock isSqliteBackend in prometheus-md-only tests for SQLite environments
On machines running OpenCode beta (v1.1.53+) with SQLite backend, getMessageDir() returns null because isSqliteBackend() returns true. This caused all 15 message-storage-dependent tests to fail. Fix: mock opencode-storage-detection to force JSON mode, and use ses_ prefixed session IDs to match getMessageDir's validation.
This commit is contained in:
parent
4cf3bc431b
commit
2a7535bb48
@ -1,16 +1,21 @@
|
|||||||
import { describe, expect, test, beforeEach, afterEach } from "bun:test"
|
import { describe, expect, test, beforeEach, afterEach, mock } from "bun:test"
|
||||||
import { mkdirSync, rmSync, writeFileSync } from "node:fs"
|
import { mkdirSync, rmSync, writeFileSync } from "node:fs"
|
||||||
import { join } from "node:path"
|
import { join } from "node:path"
|
||||||
import { tmpdir } from "node:os"
|
import { tmpdir } from "node:os"
|
||||||
import { randomUUID } from "node:crypto"
|
import { randomUUID } from "node:crypto"
|
||||||
import { SYSTEM_DIRECTIVE_PREFIX } from "../../shared/system-directive"
|
import { SYSTEM_DIRECTIVE_PREFIX } from "../../shared/system-directive"
|
||||||
import { clearSessionAgent } from "../../features/claude-code-session-state"
|
import { clearSessionAgent } from "../../features/claude-code-session-state"
|
||||||
|
// Force stable (JSON) mode for tests that rely on message file storage
|
||||||
|
mock.module("../../shared/opencode-storage-detection", () => ({
|
||||||
|
isSqliteBackend: () => false,
|
||||||
|
resetSqliteBackendCache: () => {},
|
||||||
|
}))
|
||||||
|
|
||||||
import { createPrometheusMdOnlyHook } from "./index"
|
const { createPrometheusMdOnlyHook } = await import("./index")
|
||||||
import { MESSAGE_STORAGE } from "../../features/hook-message-injector"
|
const { MESSAGE_STORAGE } = await import("../../features/hook-message-injector")
|
||||||
|
|
||||||
describe("prometheus-md-only", () => {
|
describe("prometheus-md-only", () => {
|
||||||
const TEST_SESSION_ID = "test-session-prometheus"
|
const TEST_SESSION_ID = "ses_test_prometheus"
|
||||||
let testMessageDir: string
|
let testMessageDir: string
|
||||||
|
|
||||||
function createMockPluginInput() {
|
function createMockPluginInput() {
|
||||||
@ -546,7 +551,7 @@ describe("prometheus-md-only", () => {
|
|||||||
writeFileSync(BOULDER_FILE, JSON.stringify({
|
writeFileSync(BOULDER_FILE, JSON.stringify({
|
||||||
active_plan: "/test/plan.md",
|
active_plan: "/test/plan.md",
|
||||||
started_at: new Date().toISOString(),
|
started_at: new Date().toISOString(),
|
||||||
session_ids: ["other-session-id"],
|
session_ids: ["ses_other_session_id"],
|
||||||
plan_name: "test-plan",
|
plan_name: "test-plan",
|
||||||
agent: "atlas"
|
agent: "atlas"
|
||||||
}))
|
}))
|
||||||
@ -578,7 +583,7 @@ describe("prometheus-md-only", () => {
|
|||||||
const hook = createPrometheusMdOnlyHook(createMockPluginInput())
|
const hook = createPrometheusMdOnlyHook(createMockPluginInput())
|
||||||
const input = {
|
const input = {
|
||||||
tool: "Write",
|
tool: "Write",
|
||||||
sessionID: "non-existent-session",
|
sessionID: "ses_non_existent_session",
|
||||||
callID: "call-1",
|
callID: "call-1",
|
||||||
}
|
}
|
||||||
const output = {
|
const output = {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user