db.test.ts 1002 B

12345678910111213141516171819202122232425
  1. import { describe, expect, test } from "bun:test"
  2. import path from "path"
  3. import { Flag } from "../../src/flag/flag" // kilocode_change
  4. import { Global } from "../../src/global"
  5. import { Installation } from "../../src/installation"
  6. import { Database } from "../../src/storage/db"
  7. describe("Database.Path", () => {
  8. test("returns database path for the current channel", () => {
  9. // kilocode_change start — test preload sets KILO_DB=:memory:
  10. if (Flag.KILO_DB) {
  11. const expected =
  12. Flag.KILO_DB === ":memory:" || path.isAbsolute(Flag.KILO_DB)
  13. ? Flag.KILO_DB
  14. : path.join(Global.Path.data, Flag.KILO_DB)
  15. expect(Database.Path).toBe(expected)
  16. return
  17. }
  18. // kilocode_change end
  19. const expected = ["latest", "beta"].includes(Installation.CHANNEL)
  20. ? path.join(Global.Path.data, "kilo.db")
  21. : path.join(Global.Path.data, `kilo-${Installation.CHANNEL.replace(/[^a-zA-Z0-9._-]/g, "-")}.db`)
  22. expect(Database.Path).toBe(expected)
  23. })
  24. })