fix: preserve archive on unlink failure
This commit is contained in:
@@ -231,6 +231,28 @@ try {
|
||||
);
|
||||
assert.deepEqual(await readFile(canonicalPath), canonicalBytes);
|
||||
assert.deepEqual(await readFile(boundaryPath), boundaryBytes);
|
||||
|
||||
const unlinkFailureDate = new Date("2026-08-21T12:37:56.789Z");
|
||||
const unlinkFailurePath = join(deployments, "base-sepolia.20260821T123756789Z.json");
|
||||
await assert.rejects(
|
||||
() => archiveManifest({
|
||||
root,
|
||||
network: "baseSepolia",
|
||||
now: unlinkFailureDate,
|
||||
io: {
|
||||
rm: async (path, options) => {
|
||||
if (path === canonicalPath) {
|
||||
assert.deepEqual(await readFile(unlinkFailurePath), canonicalBytes);
|
||||
throw new Error("source unlink failed");
|
||||
}
|
||||
return rm(path, options);
|
||||
},
|
||||
},
|
||||
}),
|
||||
/source unlink failed/,
|
||||
);
|
||||
assert.deepEqual(await readFile(canonicalPath), canonicalBytes);
|
||||
assert.deepEqual(await readFile(unlinkFailurePath), canonicalBytes);
|
||||
await assert.rejects(() => archiveManifest({ root, network: "anvil" }), /baseSepolia/);
|
||||
} finally {
|
||||
await rm(root, { recursive: true, force: true });
|
||||
|
||||
Reference in New Issue
Block a user