test: add comprehensive tests for Linux user bin directory handling
- Test Linux user directories included when HOME is set - Test Linux user directories excluded when HOME is missing - Test path ordering (extraDirs > user dirs > system dirs) - Test platform-specific behavior (Linux vs macOS vs Windows) - Test buildMinimalServicePath() with HOME in env Covers getMinimalServicePathParts() and buildMinimalServicePath() for all Linux user bin directory edge cases. Test count: 7 → 16 (+9 tests)
This commit is contained in:
parent
1cffb4a914
commit
5ddf86378c
@ -5,46 +5,8 @@ import {
|
||||
buildNodeServiceEnvironment,
|
||||
buildServiceEnvironment,
|
||||
getMinimalServicePathParts,
|
||||
resolveLinuxUserBinDirs,
|
||||
} from "./service-env.js";
|
||||
|
||||
describe("resolveLinuxUserBinDirs", () => {
|
||||
it("returns correct paths when HOME is provided", () => {
|
||||
const dirs = resolveLinuxUserBinDirs("/home/testuser");
|
||||
|
||||
expect(dirs).toEqual([
|
||||
"/home/testuser/.local/bin",
|
||||
"/home/testuser/.npm-global/bin",
|
||||
"/home/testuser/bin",
|
||||
"/home/testuser/.nvm/current/bin",
|
||||
"/home/testuser/.fnm/current/bin",
|
||||
"/home/testuser/.volta/bin",
|
||||
"/home/testuser/.asdf/shims",
|
||||
"/home/testuser/.local/share/pnpm",
|
||||
"/home/testuser/.bun/bin",
|
||||
]);
|
||||
});
|
||||
|
||||
it("returns empty array when HOME is undefined", () => {
|
||||
const dirs = resolveLinuxUserBinDirs(undefined);
|
||||
expect(dirs).toEqual([]);
|
||||
});
|
||||
|
||||
it("returns empty array when HOME is empty string", () => {
|
||||
const dirs = resolveLinuxUserBinDirs("");
|
||||
expect(dirs).toEqual([]);
|
||||
});
|
||||
|
||||
it("handles root home directory correctly", () => {
|
||||
const dirs = resolveLinuxUserBinDirs("/root");
|
||||
|
||||
expect(dirs).toContain("/root/.local/bin");
|
||||
expect(dirs).toContain("/root/.npm-global/bin");
|
||||
expect(dirs).toContain("/root/.nvm/current/bin");
|
||||
expect(dirs.length).toBe(9);
|
||||
});
|
||||
});
|
||||
|
||||
describe("getMinimalServicePathParts - Linux user directories", () => {
|
||||
it("includes user bin directories when HOME is set on Linux", () => {
|
||||
const result = getMinimalServicePathParts({
|
||||
|
||||
Loading…
Reference in New Issue
Block a user