|
1 | 1 | import * as path from "path"; |
2 | | -import { beforeEach, describe, it, vi } from "vitest"; |
| 2 | +import { beforeEach, describe, expect, it, vi } from "vitest"; |
3 | 3 |
|
4 | 4 | import { PathResolver } from "@/core/pathResolver"; |
5 | 5 |
|
@@ -28,6 +28,32 @@ describe("PathResolver", () => { |
28 | 28 | expectPathsEqual(pathResolver.getUrlPath(""), path.join(basePath, "url")); |
29 | 29 | }); |
30 | 30 |
|
| 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 | + |
31 | 57 | describe("getBinaryCachePath", () => { |
32 | 58 | it("should use custom binary destination when configured", () => { |
33 | 59 | mockConfig.set("coder.binaryDestination", "/custom/binary/path"); |
|
0 commit comments