feat(FN-2614): merge fusion/fn-2614 (auto-resolved)
- feat(FN-2614): complete Step 4 — configure vitest test isolation setup - test(FN-2614): complete Step 3 — add isolation companion test - feat(FN-2614): complete Step 2 — add test home isolation setup
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { homedir, tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
|
||||
const TEMP_HOME_PREFIX = "fn-test-home-";
|
||||
|
||||
describe("test isolation setup", () => {
|
||||
it("overrides process.env.HOME to a temp directory", () => {
|
||||
const home = process.env.HOME;
|
||||
|
||||
expect(home).toBeDefined();
|
||||
expect(home).toContain(tmpdir());
|
||||
expect(home).toContain(TEMP_HOME_PREFIX);
|
||||
});
|
||||
|
||||
it("resolves homedir() to the temp HOME", () => {
|
||||
const home = homedir();
|
||||
|
||||
expect(home).toContain(tmpdir());
|
||||
expect(home).toContain(TEMP_HOME_PREFIX);
|
||||
});
|
||||
|
||||
it("resolves ~/.pi/agent/AGENTS.md under the temp HOME", () => {
|
||||
const agentsPath = join(homedir(), ".pi", "agent", "AGENTS.md");
|
||||
|
||||
expect(agentsPath).toContain(tmpdir());
|
||||
expect(agentsPath).toContain(TEMP_HOME_PREFIX);
|
||||
expect(agentsPath).toMatch(/fn-test-home-.*[\\/]\.pi[\\/]agent[\\/]AGENTS\.md$/);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
import { mkdtempSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
|
||||
const tempHome = mkdtempSync(join(tmpdir(), "fn-test-home-"));
|
||||
process.env.HOME = tempHome;
|
||||
Reference in New Issue
Block a user