Skip to content

Commit 523f792

Browse files
committed
core: update database path test to verify correct channel-based filename
The test now validates that the database file is named according to the current installation channel (latest/beta get 'opencode.db', others get sanitized names). This ensures users' data is stored in the correct location based on their update channel.
1 parent 2230c3c commit 523f792

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed
Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import { describe, expect, test } from "bun:test"
2+
import path from "path"
3+
import { Installation } from "../../src/installation"
24
import { Database } from "../../src/storage/db"
35

4-
describe("Database.file", () => {
5-
test("uses the shared database for latest", () => {
6-
expect(Database.file("latest")).toBe("opencode.db")
7-
})
8-
9-
test("sanitizes preview channels for filenames", () => {
10-
expect(Database.file("fix/windows-modified-files-tracking")).toBe("opencode-fix-windows-modified-files-tracking.db")
6+
describe("Database.Path", () => {
7+
test("returns database path for the current channel", () => {
8+
const file = path.basename(Database.Path)
9+
const expected = ["latest", "beta"].includes(Installation.CHANNEL)
10+
? "opencode.db"
11+
: `opencode-${Installation.CHANNEL.replace(/[^a-zA-Z0-9._-]/g, "-")}.db`
12+
expect(file).toBe(expected)
1113
})
1214
})

0 commit comments

Comments
 (0)