diff --git a/src/lib/services/nitro-cleanup.test.ts b/src/lib/services/nitro-cleanup.test.ts index 85e75f90..e7eb235d 100644 --- a/src/lib/services/nitro-cleanup.test.ts +++ b/src/lib/services/nitro-cleanup.test.ts @@ -1,7 +1,15 @@ // @vitest-environment node import { createHash } from "node:crypto"; +import path from "node:path"; import { beforeEach, describe, expect, it, vi } from "vitest"; +const SCAN_CACHE_FILE = path.join( + process.cwd(), + "storage", + "nitro-cleanup", + "scan-cache.json", +); + type AnyFn = (...args: any[]) => any; const { @@ -490,25 +498,24 @@ describe("refreshScanCacheAfterMutation", () => { "icon\u0000/assets/icons": dirSignature([]), }; const files = installFileState({ - "/var/www/atom-nexst/storage/nitro-cleanup/scan-cache.json": - JSON.stringify({ - dirs, - result: { - fake: [ - { - fileName: "ghost.nitro", - base: "ghost", - size: 500, - dirs: ["/assets/nitro"], - lastModified: 0, - }, - ], - broken: [], - orphanedSwf: [], - orphanedIcon: [], - total: 2, - }, - }), + [SCAN_CACHE_FILE]: JSON.stringify({ + dirs, + result: { + fake: [ + { + fileName: "ghost.nitro", + base: "ghost", + size: 500, + dirs: ["/assets/nitro"], + lastModified: 0, + }, + ], + broken: [], + orphanedSwf: [], + orphanedIcon: [], + total: 2, + }, + }), }); // The directory changed after the cached scan (ghost.nitro deleted). readdirFn.mockImplementation(async (dir: string) => @@ -517,11 +524,7 @@ describe("refreshScanCacheAfterMutation", () => { await refreshScanCacheAfterMutation("nitro", ["ghost.nitro"], 1); - const written = JSON.parse( - files.get( - "/var/www/atom-nexst/storage/nitro-cleanup/scan-cache.json", - ) as string, - ) as { + const written = JSON.parse(files.get(SCAN_CACHE_FILE) as string) as { dirs: Record; result: { fake: Array<{ fileName: string }>;