Files
oh-my-pi/scripts/gen-nix-bun.test.ts
T
can1357 a69d166e00 perf(discovery): memoized WSL host-home probe per environment
- Deduplicated the re-imported changelog bullets from the PR #8403 merge,
  keeping the condensed register with only the new #8402 entry.
- getUserHomeCandidates memoizes the WSL home candidate keyed by
  platform + WSL markers + USERPROFILE, so a wedged interop pipe costs
  one bounded probe per process instead of one 500ms stall per
  discovery loader, while env changes (tests, SDK embeddings) still
  recompute.
2026-08-13 06:51:35 +02:00

26 lines
978 B
TypeScript

import { describe, expect, test } from "bun:test";
import { resolveNixBunDepsGenerator } from "./gen-nix-bun";
describe("resolveNixBunDepsGenerator", () => {
test("prefers bun2nix from the active development shell", () => {
const generator = resolveNixBunDepsGenerator(command => {
if (command === "bun2nix") return "/nix/store/bun2nix";
return "/nix/store/nix";
});
expect(generator).toEqual({ kind: "bun2nix", executable: "/nix/store/bun2nix" });
});
test("falls back to entering the Nix development shell", () => {
const generator = resolveNixBunDepsGenerator(command => (command === "nix" ? "/usr/bin/nix" : null));
expect(generator).toEqual({ kind: "nix", executable: "/usr/bin/nix" });
});
test("fails before a release mutates files when no generator is available", () => {
expect(() => resolveNixBunDepsGenerator(() => null)).toThrow(
"Generating nix/bun.nix requires bun2nix from `nix develop`, or Nix to enter that shell.",
);
});
});