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-03-21 02:49:55 +00:00
|
|
|
import { Global } from "../../src/global"
|
2026-04-16 06:03:03 +00:00
|
|
|
import { InstallationChannel } from "../../src/installation/version"
|
2026-04-16 03:30:49 +00:00
|
|
|
import { Database } from "../../src/storage"
|
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
|
|
|
})
|
|
|
|
|
})
|