Skip to content

Commit e839d13

Browse files
committed
test: add tests for getProxyLogPath log directory resolution
Covers configured path, empty/whitespace/unset fallback to default, and tilde expansion.
1 parent a518cce commit e839d13

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

test/unit/core/pathResolver.test.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as path from "path";
2-
import { beforeEach, describe, it, vi } from "vitest";
2+
import { beforeEach, describe, expect, it, vi } from "vitest";
33

44
import { PathResolver } from "@/core/pathResolver";
55

@@ -28,6 +28,32 @@ describe("PathResolver", () => {
2828
expectPathsEqual(pathResolver.getUrlPath(""), path.join(basePath, "url"));
2929
});
3030

31+
describe("getProxyLogPath", () => {
32+
const defaultLogPath = path.join(basePath, "log");
33+
34+
it.each([
35+
{ setting: "/custom/log/dir", expected: "/custom/log/dir" },
36+
{ setting: "", expected: defaultLogPath },
37+
{ setting: " ", expected: defaultLogPath },
38+
{ setting: undefined, expected: defaultLogPath },
39+
])(
40+
"should return $expected when setting is '$setting'",
41+
({ setting, expected }) => {
42+
if (setting !== undefined) {
43+
mockConfig.set("coder.proxyLogDirectory", setting);
44+
}
45+
expectPathsEqual(pathResolver.getProxyLogPath(), expected);
46+
},
47+
);
48+
49+
it("should expand tilde in configured path", () => {
50+
mockConfig.set("coder.proxyLogDirectory", "~/logs");
51+
const result = pathResolver.getProxyLogPath();
52+
expect(result).not.toContain("~");
53+
expect(result).toContain("logs");
54+
});
55+
});
56+
3157
describe("getBinaryCachePath", () => {
3258
it("should use custom binary destination when configured", () => {
3359
mockConfig.set("coder.binaryDestination", "/custom/binary/path");

0 commit comments

Comments
 (0)