embedded-search-backend.test.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import { describe, expect, it } from "vitest";
  2. import { resolveDefaultEmbeddedSearchBackend } from "../src/app/embedded-search-backend.js";
  3. describe("resolveDefaultEmbeddedSearchBackend", () => {
  4. it("uses bundled bfs, ugrep, and ripgrep paths by default", () => {
  5. expect(
  6. resolveDefaultEmbeddedSearchBackend({
  7. env: {
  8. ZCODE_BFS_BINARY: "/opt/zcode/tools/bfs/bfs",
  9. ZCODE_RG_BINARY: "/opt/zcode/tools/ripgrep/rg",
  10. ZCODE_UGREP_BINARY: "/opt/zcode/tools/ugrep/ugrep",
  11. },
  12. }),
  13. ).toEqual({
  14. kind: "native-binaries",
  15. findCommand: "/opt/zcode/tools/bfs/bfs",
  16. grepCommand: "/opt/zcode/tools/ugrep/ugrep",
  17. rgCommand: "/opt/zcode/tools/ripgrep/rg",
  18. });
  19. });
  20. it("falls back to bfs, ugrep, and rg command names when bundled paths are unavailable", () => {
  21. expect(resolveDefaultEmbeddedSearchBackend({ env: {} })).toEqual({
  22. kind: "native-binaries",
  23. findCommand: "bfs",
  24. grepCommand: "ugrep",
  25. rgCommand: "rg",
  26. });
  27. });
  28. it("preserves the explicit internal CLI compatibility override", () => {
  29. expect(
  30. resolveDefaultEmbeddedSearchBackend({
  31. env: { ZCODE_EMBEDDED_SEARCH_COMMAND: "/tmp/zcode-test" },
  32. }),
  33. ).toEqual({
  34. kind: "internal-cli",
  35. command: "/tmp/zcode-test",
  36. args: ["__internal-search"],
  37. });
  38. });
  39. });