Skip to content

Commit 2960636

Browse files
test(fileLock): state the lstat cast reason instead of doubling the assertion
Thread 4525471062 on the CodeRabbit review of PR 2383 asked for the as-unknown-as BigIntStats double assertion in src/utils/__tests__/fileLock.canonicalKey.spec.ts line 36 to go. The lstat double is read only for isSymbolicLink(), so the mock is now asserted once to BigIntStats and the four comment lines say which fields are not faked, which is the reason AGENTS.md asks to sit next to a cast that a typed API cannot express. No behaviour change and no source change: the file is a spec. Carrier: this unit is the earliest in the declared merge order (U1-U9, issue 2020 body) whose diff contains this file, so the fix lands here and the later units take it through the ancestor instead of carrying a second copy, per line 14 of comment 6767513159. PR 1914 and PR 2383 hold the identical blob 1dab157 and will point at this commit rather than repeat it. Verification, each line attributed to worktree wt-r160-1913 at node v22.23.4: - vitest run utils/__tests__/fileLock.canonicalKey.spec.ts -> 1 test file passed, 2 tests passed, exit 0. - tsc --noEmit in src (the package own check-types command) -> exit 0. - eslint --prune-suppressions --max-warnings=0 on the touched file -> exit 0; the file has no entry in src/eslint-suppressions.json before or after, so its count is 0 to 0. Summed over the whole file the counts read 2,868 before and 2,868 after, 265 file keys before and after, 0 semantic diffs; the prune run rewrote the JSON from tab indent to two-space indent (30,910 B sha256-16 5ECFDB0DB4B1F9E8 to 33,294 B sha256-16 95A8918A0E5DC809) and that churn was reverted, so this commit carries only the spec file named in its stat. - hooks: core.hooksPath is .husky/_ and pnpm run prepare regenerated 18 shims including pre-commit and pre-push; both hook bodies only refuse main, and this branch is vps2f-1913-u4-cast, so no --no-verify and no HUSKY=0 was needed.
1 parent 4132582 commit 2960636

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎src/utils/__tests__/fileLock.canonicalKey.spec.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ beforeEach(() => {
3333
mockedLock.mockReset()
3434
// alias.json is a symlink to item.json; everything else resolves to itself.
3535
mockedRealpath.mockImplementation(async (target) => (target === alias ? referent : String(target)))
36-
mockedLstat.mockImplementation(async () => ({ isSymbolicLink: () => false }) as unknown as BigIntStats)
36+
// fs/promises types lstat as returning BigIntStats and this mock only ever needs
37+
// isSymbolicLink(), so the assertion is single-step and names the subset the double
38+
// actually fakes. AGENTS.md asks for a reason next to a cast a typed API cannot
39+
// express: no test in this file reads a bigint field, so no bigint field is faked.
40+
mockedLstat.mockImplementation(async () => ({ isSymbolicLink: () => false }) as BigIntStats)
3741
mockedReadlink.mockRejectedValue(Object.assign(new Error("not a link"), { code: "EINVAL" }))
3842
})
3943

0 commit comments

Comments
 (0)