Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions test/scanner.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,41 @@ test("refuses paths that do not match the cache catalog", async (t) => {
assert.equal(result.status, "failed");
assert.match(result.error, /no longer matches a known cache rule/);
});

test("refuses removal targets outside the scan root", async (t) => {
const { root } = await fixture();
t.after(() => rm(root, { recursive: true, force: true }));

const [result] = await removeCaches(root, [
{
path: root,
relativePath: ".",
type: "node",
bytes: 0,
files: 0,
modifiedAtMs: Date.now(),
},
]);

assert.equal(result.status, "failed");
assert.match(result.error, /Refusing unsafe cache path/);
});

test("refuses stale scan results when the cache type changes", async (t) => {
const { root, paths } = await fixture();
t.after(() => rm(root, { recursive: true, force: true }));

const [result] = await removeCaches(root, [
{
path: paths.node,
relativePath: path.relative(root, paths.node),
type: "python",
bytes: 2048,
files: 1,
modifiedAtMs: Date.now(),
},
]);

assert.equal(result.status, "failed");
assert.match(result.error, /Cache type changed before removal/);
});
Loading