Skip to content

Commit 2a8b9f8

Browse files
committed
Add missing test for relative/absolute path cache convergence
The FileInformationCacheMap (added in #13955) normalizes keys so that relative and absolute paths to the same file share one cache entry. This adds the test case that was missing from the original test suite.
1 parent 70ad31d commit 2a8b9f8

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

tests/unit/project/file-information-cache.test.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
import { unitTest } from "../../test.ts";
1111
import { assert } from "testing/asserts";
12-
import { join } from "../../../src/deno_ral/path.ts";
12+
import { join, relative } from "../../../src/deno_ral/path.ts";
1313
import {
1414
ensureFileInformationCache,
1515
FileInformationCacheMap,
@@ -107,3 +107,26 @@ unitTest(
107107
);
108108
},
109109
);
110+
111+
// deno-lint-ignore require-await
112+
unitTest(
113+
"fileInformationCache - relative and absolute paths share same entry",
114+
async () => {
115+
const project = createMockProjectContext();
116+
117+
const absolutePath = join(project.dir, "subdir", "page.qmd");
118+
const relativePath = relative(Deno.cwd(), absolutePath);
119+
120+
const entry1 = ensureFileInformationCache(project, relativePath);
121+
const entry2 = ensureFileInformationCache(project, absolutePath);
122+
123+
assert(
124+
entry1 === entry2,
125+
"Relative and absolute paths to same file should share a cache entry",
126+
);
127+
assert(
128+
project.fileInformationCache.size === 1,
129+
"Should have exactly one cache entry",
130+
);
131+
},
132+
);

0 commit comments

Comments
 (0)