fix: select rollback artifact pairs atomically
This commit is contained in:
@@ -100,8 +100,10 @@ async function releaseV2With(
|
||||
|
||||
function artifactReader(
|
||||
entries: Readonly<Record<string, unknown | Error>>,
|
||||
reads: string[] = [],
|
||||
): (path: string) => Promise<unknown> {
|
||||
return async (path) => {
|
||||
reads.push(path);
|
||||
const value = entries[path];
|
||||
if (value === undefined) {
|
||||
throw Object.assign(new Error(`missing ${path}`), { code: "ENOENT" });
|
||||
@@ -315,11 +317,54 @@ describe("release coherence", () => {
|
||||
}),
|
||||
).resolves.toMatchObject({ coherence: { compatible: false } });
|
||||
|
||||
const releaseOnlyMissingReads: string[] = [];
|
||||
await expect(
|
||||
verifyRollbackReleaseCoherence({
|
||||
readArtifact: artifactReader(validPublic),
|
||||
readArtifact: artifactReader(
|
||||
{
|
||||
"dist/config.json": runtimeV2,
|
||||
...validPublic,
|
||||
},
|
||||
releaseOnlyMissingReads,
|
||||
),
|
||||
contractPackages,
|
||||
}),
|
||||
).rejects.toThrow("primary rollback artifact pair");
|
||||
expect(releaseOnlyMissingReads).toEqual([
|
||||
"dist/release-manifest.json",
|
||||
"dist/config.json",
|
||||
]);
|
||||
|
||||
const runtimeOnlyMissingReads: string[] = [];
|
||||
await expect(
|
||||
verifyRollbackReleaseCoherence({
|
||||
readArtifact: artifactReader(
|
||||
{
|
||||
"dist/release-manifest.json": exactV2,
|
||||
...validPublic,
|
||||
},
|
||||
runtimeOnlyMissingReads,
|
||||
),
|
||||
contractPackages,
|
||||
}),
|
||||
).rejects.toThrow("primary rollback artifact pair");
|
||||
expect(runtimeOnlyMissingReads).toEqual([
|
||||
"dist/release-manifest.json",
|
||||
"dist/config.json",
|
||||
]);
|
||||
|
||||
const missingPairReads: string[] = [];
|
||||
await expect(
|
||||
verifyRollbackReleaseCoherence({
|
||||
readArtifact: artifactReader(validPublic, missingPairReads),
|
||||
contractPackages,
|
||||
}),
|
||||
).resolves.toMatchObject({ coherence: { compatible: true } });
|
||||
expect(missingPairReads).toEqual([
|
||||
"dist/release-manifest.json",
|
||||
"dist/config.json",
|
||||
"public/release-manifest.json",
|
||||
"public/config.json",
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user