





















@@ -36,6 +36,10 @@ describe("media store", () => {
3636return await fn(store, home);
3737}
383839+async function expectPathMissing(targetPath: string): Promise<void> {
40+await expect(fs.stat(targetPath)).rejects.toMatchObject({ code: "ENOENT" });
41+}
42+3943async function expectOriginalFilenameCase(params: {
4044filename: string;
4145expected: string;
@@ -216,7 +220,7 @@ describe("media store", () => {
216220const past = Date.now() - 10_000;
217221await fs.utimes(saved.path, past / 1000, past / 1000);
218222await store.cleanOldMedia(1);
219-await expect(fs.stat(saved.path)).rejects.toThrow();
223+await expectPathMissing(saved.path);
220224},
221225});
222226}
@@ -290,14 +294,14 @@ describe("media store", () => {
290294const state = await params.setup(store);
291295await params.run(store);
292296for (const removedFile of state.removedFiles) {
293-await expect(fs.stat(removedFile)).rejects.toThrow();
297+await expectPathMissing(removedFile);
294298}
295299for (const preservedFile of state.preservedFiles) {
296300const stat = await fs.stat(preservedFile);
297301expect(stat.isFile()).toBe(true);
298302}
299303for (const removedDir of state.removedDirs ?? []) {
300-await expect(fs.stat(removedDir)).rejects.toThrow();
304+await expectPathMissing(removedDir);
301305}
302306for (const preservedDir of state.preservedDirs ?? []) {
303307const stat = await fs.stat(preservedDir);
@@ -420,7 +424,7 @@ describe("media store", () => {
420424await expect(
421425store.saveMediaBuffer(Buffer.from("escape"), "text/plain", traversalSubdir),
422426).rejects.toThrow("unsafe media subdir");
423-await expect(fs.stat(outsideDir)).rejects.toThrow();
427+await expectPathMissing(outsideDir);
424428});
425429},
426430},
@@ -513,7 +517,7 @@ describe("media store", () => {
513517514518await store.cleanOldMedia(1);
515519516-await expect(fs.stat(saved.path)).rejects.toThrow();
520+await expectPathMissing(saved.path);
517521const inboundStat = await fs.stat(inboundDir);
518522expect(inboundStat.isDirectory()).toBe(true);
519523});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。