test: fix addressed registry step11 regressions
This commit is contained in:
@@ -1,2 +1,79 @@
|
||||
import {describe,expect,it} from "vitest"; import {RegistryAddressedPublicationStore,canonicalBootstrapRequestDigest} from "../src/workspaces/registry-publication.js"; import {mkdtemp} from "node:fs/promises"; import {join} from "node:path";
|
||||
describe("addressed publication",()=>{it("claims and advances a durable job",async()=>{const root=await mkdtemp(join(process.env.TMPDIR??"/tmp","thoth-pub-")); const base={kind:"bootstrap" as const,installation:{installationId:"i",digest:"a".repeat(64)},repository:{remote:"r",branch:"main",head:"",digest:"b".repeat(64)},remote:{remote:"r",head:"",digest:"c".repeat(64)},workspaceIds:[] as string[]}; const req={...base,requestDigest:canonicalBootstrapRequestDigest(base)}; const s=new RegistryAddressedPublicationStore(root); const x=await s.claim(req); expect((await s.transition(x.runId,"target_advertised")).phase).toBe("target_advertised");});});
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { mkdtemp } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import {
|
||||
RegistryAddressedPublicationStore,
|
||||
type RegistryAddressedRequestV1,
|
||||
} from "../src/workspaces/registry-publication.js";
|
||||
|
||||
describe("addressed publication", () => {
|
||||
it("claims a complete pull context and advances only through legal phases", async () => {
|
||||
const root = await mkdtemp(join(process.env.TMPDIR ?? "/tmp", "thoth-pub-"));
|
||||
const runId = "a".repeat(32);
|
||||
const baseCommit = "b".repeat(40);
|
||||
const targetCommit = "c".repeat(40);
|
||||
const base = {
|
||||
commit: baseCommit,
|
||||
manifestSha256: "d".repeat(64),
|
||||
workspaces: [{
|
||||
workspaceId: "workspace-a" as any,
|
||||
revision: "e".repeat(40) as any,
|
||||
descriptorBlob: "f".repeat(40) as any,
|
||||
manifestSha256: "0".repeat(64) as any,
|
||||
}],
|
||||
};
|
||||
const request: RegistryAddressedRequestV1 = {
|
||||
mode: "create",
|
||||
operation: "registry_pull",
|
||||
runId: runId as any,
|
||||
requestSha256: "1".repeat(64) as any,
|
||||
installationIdentitySha256: "2".repeat(64) as any,
|
||||
repositoryIdentitySha256: "3".repeat(64) as any,
|
||||
expectedBaseCommit: baseCommit as any,
|
||||
remoteRefIdentitySha256: "4".repeat(64) as any,
|
||||
};
|
||||
const store = new RegistryAddressedPublicationStore(root);
|
||||
|
||||
const claimed = await store.claim(request, base);
|
||||
expect(claimed).toMatchObject({
|
||||
operation: "registry_pull",
|
||||
baseCommit,
|
||||
baseManifestSha256: base.manifestSha256,
|
||||
baseWorkspaces: base.workspaces,
|
||||
phase: "request_claimed",
|
||||
});
|
||||
const advertised = await store.transition(runId as any, "target_advertised", {
|
||||
advertisedTargetCommit: targetCommit as any,
|
||||
immutableTargetRef: `refs/thoth/addressed-runs/${runId}/target`,
|
||||
});
|
||||
expect(advertised.phase).toBe("target_advertised");
|
||||
const fetched = await store.transition(runId as any, "target_fetched", {
|
||||
fetchedTargetCommit: targetCommit as any,
|
||||
});
|
||||
expect(fetched.phase).toBe("target_fetched");
|
||||
const planned = await store.transition(runId as any, "planned", {
|
||||
targetCommit: targetCommit as any,
|
||||
targetManifestSha256: "5".repeat(64) as any,
|
||||
targetWorkspaces: [],
|
||||
changedWorkspaceIds: ["workspace-a" as any],
|
||||
changedSetSha256: "6".repeat(64) as any,
|
||||
changedSetRule: "symmetric_base_target_workspace_difference",
|
||||
planSha256: "7".repeat(64) as any,
|
||||
});
|
||||
expect(planned.phase).toBe("planned");
|
||||
expect((await store.transition(runId as any, "participants_prepared", {
|
||||
participantsSha256: "8".repeat(64) as any,
|
||||
synchronizersSha256: "9".repeat(64) as any,
|
||||
})).phase).toBe("participants_prepared");
|
||||
expect((await store.transition(runId as any, "publication_intent_durable", {
|
||||
publicationIntentSha256: "a".repeat(64) as any,
|
||||
})).phase).toBe("publication_intent_durable");
|
||||
expect((await store.transition(runId as any, "target_published", {
|
||||
publishedActiveStateSha256: "b".repeat(64) as any,
|
||||
})).phase).toBe("target_published");
|
||||
expect((await store.transition(runId as any, "terminal_durable", {
|
||||
terminalResultSha256: "c".repeat(64) as any,
|
||||
terminalPublication: "target",
|
||||
})).phase).toBe("terminal_durable");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user