fix: use try/finally for env cleanup in test
Ensures process.env.HOME is restored even if assertions fail, preventing flaky behavior in subsequent tests. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
3ef9f89e8f
commit
27adb1d677
1 changed files with 7 additions and 6 deletions
|
|
@ -130,12 +130,13 @@ describe("resolveWorkingDirectory", () => {
|
|||
describe("fallback behavior", () => {
|
||||
it("should fall back to HOME when no valid URIs", () => {
|
||||
const originalHome = process.env.HOME;
|
||||
process.env.HOME = "/test/home";
|
||||
|
||||
const result = resolveWorkingDirectory([]);
|
||||
expect(result).toBe("/test/home");
|
||||
|
||||
process.env.HOME = originalHome;
|
||||
try {
|
||||
process.env.HOME = "/test/home";
|
||||
const result = resolveWorkingDirectory([]);
|
||||
expect(result).toBe("/test/home");
|
||||
} finally {
|
||||
process.env.HOME = originalHome;
|
||||
}
|
||||
});
|
||||
|
||||
it("should handle empty workspace dirs array", () => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue