

























@@ -188,6 +188,10 @@ async function seedStaleLock(lockPath: string) {
188188);
189189}
190190191+async function expectPathMissing(targetPath: string): Promise<void> {
192+await expect(fs.access(targetPath)).rejects.toMatchObject({ code: "ENOENT" });
193+}
194+191195describe("registry race safety", () => {
192196it("does not migrate legacy registry files from runtime reads", async () => {
193197await seedContainerRegistry([containerEntry({ containerName: "legacy-container" })]);
@@ -246,10 +250,10 @@ describe("registry race safety", () => {
246250expect.objectContaining({ kind: "browsers", status: "migrated", entries: 1 }),
247251]);
248252249-await expect(fs.access(SANDBOX_REGISTRY_PATH)).rejects.toThrow();
250-await expect(fs.access(SANDBOX_BROWSER_REGISTRY_PATH)).rejects.toThrow();
251-await expect(fs.access(`${SANDBOX_REGISTRY_PATH}.lock`)).rejects.toThrow();
252-await expect(fs.access(`${SANDBOX_BROWSER_REGISTRY_PATH}.lock`)).rejects.toThrow();
253+await expectPathMissing(SANDBOX_REGISTRY_PATH);
254+await expectPathMissing(SANDBOX_BROWSER_REGISTRY_PATH);
255+await expectPathMissing(`${SANDBOX_REGISTRY_PATH}.lock`);
256+await expectPathMissing(`${SANDBOX_BROWSER_REGISTRY_PATH}.lock`);
253257await expect(readRegistry()).resolves.toEqual({
254258entries: [
255259expect.objectContaining({
@@ -353,7 +357,7 @@ describe("registry race safety", () => {
353357const registry = await readRegistry();
354358355359expect(registry.entries.map((entry) => entry.containerName)).toEqual(["../escape"]);
356-await expect(fs.access(`${TEST_STATE_DIR}/escape.json`)).rejects.toThrow();
360+await expectPathMissing(`${TEST_STATE_DIR}/escape.json`);
357361});
358362359363it("returns registry entries in deterministic container-name order", async () => {
@@ -408,8 +412,8 @@ describe("registry race safety", () => {
408412await seedMalformedBrowserRegistry("{bad json");
409413const results = await migrateLegacySandboxRegistryFiles();
410414411-await expect(fs.access(SANDBOX_REGISTRY_PATH)).rejects.toThrow();
412-await expect(fs.access(SANDBOX_BROWSER_REGISTRY_PATH)).rejects.toThrow();
415+await expectPathMissing(SANDBOX_REGISTRY_PATH);
416+await expectPathMissing(SANDBOX_BROWSER_REGISTRY_PATH);
413417expect(results.map((result) => result.status)).toEqual([
414418"quarantined-invalid",
415419"quarantined-invalid",
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。