| 1234567891011121314151617181920212223242526272829 |
- import { describe, expect } from "bun:test"
- import path from "path"
- import { Effect } from "effect"
- import { Global } from "@opencode-ai/core/global"
- import { InstallationChannel } from "@opencode-ai/core/installation/version"
- import { RuntimeFlags } from "@/effect/runtime-flags"
- import { Database } from "@/storage/db"
- import { it } from "../lib/effect"
- describe("Database.getChannelPath", () => {
- it.effect("returns database path for the current channel", () =>
- Effect.gen(function* () {
- const flags = yield* RuntimeFlags.Service
- const expected = ["latest", "beta", "prod"].includes(InstallationChannel)
- ? path.join(Global.Path.data, "opencode.db")
- : path.join(Global.Path.data, `opencode-${InstallationChannel.replace(/[^a-zA-Z0-9._-]/g, "-")}.db`)
- expect(Database.getChannelPath(flags)).toBe(expected)
- }).pipe(Effect.provide(RuntimeFlags.layer())),
- )
- it.effect("uses the shared database path when channel databases are disabled", () =>
- Effect.gen(function* () {
- const flags = yield* RuntimeFlags.Service
- expect(Database.getChannelPath(flags)).toBe(path.join(Global.Path.data, "opencode.db"))
- }).pipe(Effect.provide(RuntimeFlags.layer({ disableChannelDb: true }))),
- )
- })
|