




























@@ -18,6 +18,10 @@ async function expectRegularFile(filePath: string): Promise<void> {
1818expect((await fs.stat(filePath)).isFile()).toBe(true);
1919}
202021+async function expectPathMissing(filePath: string): Promise<void> {
22+await expect(fs.stat(filePath)).rejects.toMatchObject({ code: "ENOENT" });
23+}
24+2125describe("config backup rotation", () => {
2226it("keeps a 5-deep backup ring for config writes", async () => {
2327await withTempHome(async () => {
@@ -55,7 +59,7 @@ describe("config backup rotation", () => {
5559await expect(readName(".bak.2")).resolves.toBe("v3");
5660await expect(readName(".bak.3")).resolves.toBe("v2");
5761await expect(readName(".bak.4")).resolves.toBe("v1");
58-await expect(fs.stat(`${configPath}.bak.5`)).rejects.toThrow();
62+await expectPathMissing(`${configPath}.bak.5`);
5963});
6064});
6165@@ -101,9 +105,9 @@ describe("config backup rotation", () => {
101105await expectRegularFile(`${configPath}.bak.2`);
102106103107// Orphans removed
104-await expect(fs.stat(`${configPath}.bak.1772352289`)).rejects.toThrow();
105-await expect(fs.stat(`${configPath}.bak.before-marketing`)).rejects.toThrow();
106-await expect(fs.stat(`${configPath}.bak.99`)).rejects.toThrow();
108+await expectPathMissing(`${configPath}.bak.1772352289`);
109+await expectPathMissing(`${configPath}.bak.before-marketing`);
110+await expectPathMissing(`${configPath}.bak.99`);
107111108112// Main config untouched
109113await expect(fs.readFile(configPath, "utf-8")).resolves.toBe("current");
@@ -132,7 +136,7 @@ describe("config backup rotation", () => {
132136expectPosixMode(primaryBackupStat.mode, 0o600);
133137}
134138// Out-of-ring orphan gets pruned.
135-await expect(fs.stat(`${configPath}.bak.orphan`)).rejects.toThrow();
139+await expectPathMissing(`${configPath}.bak.orphan`);
136140});
137141});
138142});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。