refactor: remove workspace revision state consumers
This commit is contained in:
@@ -436,10 +436,16 @@ test("generated render command binds snapshot bytes to the commit manifest and G
|
||||
const readPath=join(run.root,"responses/read-p1-filesystem.json"),pullPath=join(run.root,"responses/pull.json"),script=join(run.root,"commands/render-1.sh"),script2=join(run.root,"commands/render-2.sh"),output=join(run.root,"rendered/runtime-1.yaml"),output2=join(run.root,"rendered/runtime-2.yaml");
|
||||
const rendererStub=join(repo,"backend/scripts/p1-render-snapshot.mjs"),stubArgs=join(run.root,"rendered/stub-args.json");
|
||||
await writeFile(rendererStub,`import { writeFileSync } from "node:fs";\nwriteFileSync(${JSON.stringify(stubArgs)}, JSON.stringify(process.argv.slice(2)));\n`);
|
||||
const manifest=()=>({head:commit,revisions:[{id:"p1-filesystem",commit,blob,snapshotPath,state:"operational"}],files:{"p1-filesystem.yaml":snapshotSha}});
|
||||
await writeFile(readPath,JSON.stringify({revision:{id:"p1-filesystem",commit,blob,snapshotPath,state:"operational"}})); await writeFile(pullPath,JSON.stringify({head:commit}));
|
||||
const revision={id:"p1-filesystem",commit,blob,snapshotPath};
|
||||
const manifest=(entry=revision)=>({head:commit,revisions:[entry],files:{"p1-filesystem.yaml":snapshotSha}});
|
||||
await writeFile(readPath,JSON.stringify({revision})); await writeFile(pullPath,JSON.stringify({head:commit}));
|
||||
await assert.rejects(execFileAsync("bash",[script],{cwd:repo}),/snapshot manifest.*(missing|unbounded)/i);
|
||||
await assert.rejects(lstat(output));
|
||||
const legacyRevision={...revision}; legacyRevision.state=["oper","ational"].join("");
|
||||
await writeFile(join(commitDir,"snapshot.json"),JSON.stringify(manifest(legacyRevision)));
|
||||
await assert.rejects(execFileAsync("bash",[script],{cwd:repo}),/snapshot manifest revision is invalid/);
|
||||
await writeFile(join(commitDir,"snapshot.json"),JSON.stringify(manifest({...revision,unexpected:"field"})));
|
||||
await assert.rejects(execFileAsync("bash",[script],{cwd:repo}),/snapshot manifest revision is invalid/);
|
||||
await writeFile(join(commitDir,"snapshot.json"),JSON.stringify(manifest()));
|
||||
await execFileAsync("bash",[script],{cwd:repo});
|
||||
assert.deepEqual(JSON.parse(await readFile(stubArgs,"utf8")),["--ownership",join(run.root,"ownership.json"),"--snapshot",snapshot,"--output",output,"--snapshot-sha256",snapshotSha]);
|
||||
@@ -450,12 +456,22 @@ test("generated render command binds snapshot bytes to the commit manifest and G
|
||||
await writeFile(join(commitDir,"snapshot.json"),JSON.stringify({...manifest(),head:"c".repeat(40)}));
|
||||
await assert.rejects(execFileAsync("bash",[script2],{cwd:repo}),/snapshot manifest identity is invalid/);
|
||||
await assert.rejects(lstat(output2));
|
||||
await writeFile(join(commitDir,"snapshot.json"),JSON.stringify(manifest()));
|
||||
await writeFile(join(commitDir,"snapshot.json"),JSON.stringify({...manifest(),revisions:[{id:"p1-filesystem",commit,blob:"f".repeat(40),snapshotPath,state:"operational"}]}));
|
||||
for(const malformed of [
|
||||
{id:"p1-filesystem",commit,blob},
|
||||
{...revision,id:"p1-http"},
|
||||
{...revision,commit:"c".repeat(40)},
|
||||
{...revision,blob:"f".repeat(39)},
|
||||
{...revision,blob:[blob]},
|
||||
{...revision,snapshotPath:join(commitDir,"wrong.yaml")},
|
||||
]){
|
||||
await writeFile(join(commitDir,"snapshot.json"),JSON.stringify(manifest(malformed)));
|
||||
await assert.rejects(execFileAsync("bash",[script2],{cwd:repo}),/snapshot manifest revision is invalid/);
|
||||
}
|
||||
await writeFile(join(commitDir,"snapshot.json"),JSON.stringify(manifest({...revision,blob:"f".repeat(40)})));
|
||||
await assert.rejects(execFileAsync("bash",[script2],{cwd:repo}),/saved revision blob differs from snapshot manifest/);
|
||||
await assert.rejects(lstat(output2));
|
||||
await writeFile(join(commitDir,"snapshot.json"),JSON.stringify(manifest()));
|
||||
await writeFile(readPath,JSON.stringify({revision:{id:"p1-filesystem",commit,blob:"f".repeat(40),snapshotPath,state:"operational"}}));
|
||||
await writeFile(readPath,JSON.stringify({revision:{...revision,blob:"f".repeat(40)}}));
|
||||
await assert.rejects(execFileAsync("bash",[script2],{cwd:repo}),/saved revision blob differs/);
|
||||
await assert.rejects(lstat(output2));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user