forked from NoeFabris/opencode-antigravity-auth
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug.test.ts
More file actions
78 lines (63 loc) · 2.4 KB
/
Copy pathdebug.test.ts
File metadata and controls
78 lines (63 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"
import { DEFAULT_CONFIG } from "./config"
const { ensureGitignoreSyncMock } = vi.hoisted(() => ({
ensureGitignoreSyncMock: vi.fn(),
}))
vi.mock("./storage", () => ({
ensureGitignoreSync: ensureGitignoreSyncMock,
}))
describe("debug sink policy", () => {
let originalDebugEnv: string | undefined
let originalDebugTuiEnv: string | undefined
beforeEach(() => {
vi.resetModules()
originalDebugEnv = process.env.OPENCODE_ANTIGRAVITY_DEBUG
originalDebugTuiEnv = process.env.OPENCODE_ANTIGRAVITY_DEBUG_TUI
delete process.env.OPENCODE_ANTIGRAVITY_DEBUG
delete process.env.OPENCODE_ANTIGRAVITY_DEBUG_TUI
ensureGitignoreSyncMock.mockReset()
})
afterEach(() => {
if (originalDebugEnv === undefined) {
delete process.env.OPENCODE_ANTIGRAVITY_DEBUG
} else {
process.env.OPENCODE_ANTIGRAVITY_DEBUG = originalDebugEnv
}
if (originalDebugTuiEnv === undefined) {
delete process.env.OPENCODE_ANTIGRAVITY_DEBUG_TUI
} else {
process.env.OPENCODE_ANTIGRAVITY_DEBUG_TUI = originalDebugTuiEnv
}
})
it("keeps debug_tui independent from debug in config", async () => {
const { initializeDebug, isDebugEnabled, isDebugTuiEnabled, getLogFilePath } = await import("./debug")
initializeDebug({
...DEFAULT_CONFIG,
debug: false,
debug_tui: true,
})
expect(isDebugEnabled()).toBe(false)
expect(isDebugTuiEnabled()).toBe(true)
expect(getLogFilePath()).toBeUndefined()
})
it("keeps debug_tui independent from debug in env fallback", async () => {
process.env.OPENCODE_ANTIGRAVITY_DEBUG = "0"
process.env.OPENCODE_ANTIGRAVITY_DEBUG_TUI = "1"
const { isDebugEnabled, isDebugTuiEnabled, getLogFilePath } = await import("./debug")
expect(isDebugEnabled()).toBe(false)
expect(isDebugTuiEnabled()).toBe(true)
expect(getLogFilePath()).toBeUndefined()
})
it("keeps file debug enabled without TUI when only debug is true", async () => {
const { initializeDebug, isDebugEnabled, isDebugTuiEnabled, getLogFilePath } = await import("./debug")
initializeDebug({
...DEFAULT_CONFIG,
debug: true,
debug_tui: false,
log_dir: "/tmp/opencode-antigravity-debug-tests",
})
expect(isDebugEnabled()).toBe(true)
expect(isDebugTuiEnabled()).toBe(false)
expect(getLogFilePath()).toContain("antigravity-debug-")
})
})