test: prove P1 configuration process end to end
This commit is contained in:
@@ -207,6 +207,29 @@ async function fixture(workspaceSource = validYaml): Promise<{
|
||||
return { root, remote, source, initialCommit: stdout.trim() };
|
||||
}
|
||||
|
||||
async function contentOnlyFixture(): Promise<{
|
||||
root: string; remote: string; source: string; initialCommit: string;
|
||||
}> {
|
||||
const root = mkdtempSync(join(tmpdir(), "thoth-workspace-registry-empty-"));
|
||||
temporaryRoots.push(root);
|
||||
const remote = join(root, "remote.git");
|
||||
const source = join(root, "source");
|
||||
await git(root, ["init", "--bare", "--initial-branch=main", remote]);
|
||||
mkdirSync(source);
|
||||
await git(source, ["init", "--initial-branch=main"]);
|
||||
await git(source, ["config", "user.name", "Workspace Registry Test"]);
|
||||
await git(source, ["config", "user.email", "workspace-registry@example.invalid"]);
|
||||
const evidence = join(source, "workspace-content", "p1-filesystem", "evidence");
|
||||
mkdirSync(evidence, { recursive: true });
|
||||
writeFileSync(join(evidence, "guide.md"), "curated content\n");
|
||||
await git(source, ["add", "workspace-content"]);
|
||||
await git(source, ["commit", "-m", "Bootstrap curated content"]);
|
||||
await git(source, ["remote", "add", "origin", remote]);
|
||||
await git(source, ["push", "origin", "main"]);
|
||||
const initialCommit = await gitOutput(source, ["rev-parse", "HEAD"]);
|
||||
return { root, remote, source, initialCommit };
|
||||
}
|
||||
|
||||
async function multiWorkspaceFixture(workspaces: Record<string, string>): Promise<{
|
||||
root: string; remote: string; source: string; initialCommit: string;
|
||||
}> {
|
||||
@@ -318,6 +341,29 @@ function persistPreStateManifest(root: string, commit: string): void {
|
||||
writeFileSync(snapshotPath, JSON.stringify(manifest));
|
||||
}
|
||||
|
||||
test("allows first API publication and delete-last from a content-only registry base", async () => {
|
||||
const remote = await contentOnlyFixture();
|
||||
const registry = new WorkspaceRegistry(config(join(remote.root, "registry"), remote.remote));
|
||||
|
||||
await expect(registry.bootstrap()).resolves.toMatchObject({ head: remote.initialCommit });
|
||||
await expect(registry.list()).resolves.toEqual([]);
|
||||
|
||||
const created = await registry.publish({
|
||||
action: "create",
|
||||
workspace: filesystemWorkspace("p1-filesystem"),
|
||||
baseCommit: remote.initialCommit,
|
||||
});
|
||||
expect(created).toMatchObject({ id: "p1-filesystem" });
|
||||
|
||||
await expect(registry.publish({
|
||||
action: "delete",
|
||||
id: "p1-filesystem",
|
||||
baseCommit: created!.commit,
|
||||
baseBlob: created!.blob,
|
||||
})).resolves.toBeUndefined();
|
||||
await expect(registry.list()).resolves.toEqual([]);
|
||||
});
|
||||
|
||||
test("bootstraps a checkout and activates a validated immutable snapshot", async () => {
|
||||
const remote = await fixture();
|
||||
const registry = new WorkspaceRegistry(config(join(remote.root, "registry"), remote.remote));
|
||||
|
||||
Reference in New Issue
Block a user