storageRootsResolver.test.ts 965 B

123456789101112131415161718192021222324
  1. import { describe, expect, it } from "vitest";
  2. import { join, resolve } from "node:path";
  3. import { resolveStorageRoots } from "../src/storage/adapters/rootsResolver.js";
  4. describe("resolveStorageRoots", () => {
  5. it("returns only the home root when the data base dir is the home dir", () => {
  6. expect(resolveStorageRoots({ homeDir: "/Users/u", dataBaseDir: "/Users/u/" })).toEqual([
  7. { id: "home", path: join(resolve("/Users/u"), ".zcode"), hasCustomDataBaseDir: false },
  8. ]);
  9. });
  10. it("adds the custom data base dir root and flags the home root as having a stale v2 copy", () => {
  11. expect(
  12. resolveStorageRoots({ homeDir: "/Users/u", dataBaseDir: "/Volumes/Data/zcode" }),
  13. ).toEqual([
  14. { id: "home", path: join(resolve("/Users/u"), ".zcode"), hasCustomDataBaseDir: true },
  15. {
  16. id: "dataBaseDir",
  17. path: join(resolve("/Volumes/Data/zcode"), ".zcode"),
  18. hasCustomDataBaseDir: true,
  19. },
  20. ]);
  21. });
  22. });