test(pi): pin command body cache immutability after file changes

This commit is contained in:
quark404 committed 2026-11-01 10:48:36 +00:00
1 parent c8cbb0ee05
commit 65e47bb1e2
1 file changed
+27
+27
View File
@@ -1951,6 +1951,33 @@ async function main() {
"the cache should return the same body on subsequent lookups"
)
}],
["command body cache returns the first body after the backing file changes", () => {
const root = fs.mkdtempSync(path.join(os.tmpdir(), "ecc-pi-cache-"))
const commandsDir = path.join(root, "commands")
fs.mkdirSync(commandsDir, { recursive: true })
const planPath = path.join(commandsDir, "plan.md")
fs.writeFileSync(planPath, "---\ndescription: plan\n---\nfirst body\n")
try {
const readBody = createCommandBodyReader(root)
assert.strictEqual(readBody("plan"), "first body")
fs.writeFileSync(planPath, "---\ndescription: plan\n---\nsecond body\n")
assert.strictEqual(
loadPlaceholderlessCommand("plan", root),
"second body",
"the backing command file must actually change for the cache assertion to be meaningful"
)
assert.strictEqual(
readBody("plan"),
"first body",
"the cached body must be immutable even after the backing command file changes"
)
} finally {
fs.rmSync(root, { recursive: true, force: true })
}
}],
]
for (const [name, fn] of tests) {