forked from NoeFabris/opencode-antigravity-auth
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogger.test.ts
More file actions
80 lines (64 loc) · 1.99 KB
/
Copy pathlogger.test.ts
File metadata and controls
80 lines (64 loc) · 1.99 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
79
80
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"
import { DEFAULT_CONFIG } from "./config"
import type { PluginClient } from "./types"
const { ensureGitignoreSyncMock } = vi.hoisted(() => ({
ensureGitignoreSyncMock: vi.fn(),
}))
vi.mock("./storage", () => ({
ensureGitignoreSync: ensureGitignoreSyncMock,
}))
describe("logger sink routing", () => {
beforeEach(() => {
vi.resetModules()
ensureGitignoreSyncMock.mockReset()
})
afterEach(async () => {
const { initializeDebug } = await import("./debug")
initializeDebug(DEFAULT_CONFIG)
})
it("routes logs to TUI when debug_tui is enabled without file debug", async () => {
const { initializeDebug } = await import("./debug")
const { createLogger, initLogger } = await import("./logger")
initializeDebug({
...DEFAULT_CONFIG,
debug: false,
debug_tui: true,
})
const appLog = vi.fn().mockResolvedValue(undefined)
const client = {
app: {
log: appLog,
},
} as unknown as PluginClient
initLogger(client)
createLogger("request").debug("thinking-resolution", { status: 429 })
expect(appLog).toHaveBeenCalledTimes(1)
expect(appLog).toHaveBeenCalledWith({
body: {
service: "antigravity.request",
level: "debug",
message: "thinking-resolution",
extra: { status: 429 },
},
})
})
it("does not route to TUI when only file debug is enabled", async () => {
const { initializeDebug } = await import("./debug")
const { createLogger, initLogger } = await import("./logger")
initializeDebug({
...DEFAULT_CONFIG,
debug: true,
debug_tui: false,
log_dir: "/tmp/opencode-antigravity-logger-tests",
})
const appLog = vi.fn().mockResolvedValue(undefined)
const client = {
app: {
log: appLog,
},
} as unknown as PluginClient
initLogger(client)
createLogger("request").debug("file-only")
expect(appLog).not.toHaveBeenCalled()
})
})