2026-03-07 04:34:29 +00:00
|
|
|
import { describe, expect, test } from "bun:test"
|
2026-03-07 23:52:35 +00:00
|
|
|
import path from "path"
|
2026-04-25 17:51:37 +00:00
|
|
|
import { Global } from "@opencode-ai/core/global"
|
2026-04-25 17:29:52 +00:00
|
|
|
import { InstallationChannel } from "@opencode-ai/core/installation/version"
|
2026-04-27 18:33:33 +00:00
|
|
|
import { Database } from "@/storage/db"
|
2026-03-07 04:34:29 +00:00
|
|
|
|
2026-03-07 23:52:35 +00:00
|
|
|
describe("Database.Path", () => {
|
|
|
|
|
test("returns database path for the current channel", () => {
|
2026-04-16 06:03:03 +00:00
|
|
|
const expected = ["latest", "beta"].includes(InstallationChannel)
|
2026-03-25 14:47:40 +00:00
|
|
|
? path.join(Global.Path.data, "opencode.db")
|
2026-04-16 06:03:03 +00:00
|
|
|
: path.join(Global.Path.data, `opencode-${InstallationChannel.replace(/[^a-zA-Z0-9._-]/g, "-")}.db`)
|
2026-03-25 14:47:40 +00:00
|
|
|
expect(Database.getChannelPath()).toBe(expected)
|
2026-03-07 04:34:29 +00:00
|
|
|
})
|
|
|
|
|
})
|