docs(tests): explain IndexedDB rollback and depot collection scenarios
This commit is contained in:
@@ -46,13 +46,12 @@ export async function assetDepotStorageCase(assert){
|
||||
// 摘要/元数据冲突必须整批拒绝,不能推进 rootRevision 或写入部分共享字节。
|
||||
await rejects(()=>storage.commit(q,{image:image(2),depot:cut([], [{ref:{...ref('one'),digest:'0'.repeat(64)},bytes}])}),'shared_asset_bytes_changed');assert((await storage.recover(q)).rootRevision===1,'invalid bytes advanced Root');
|
||||
await rejects(()=>storage.commit(q,{image:image(2),depot:cut([['one',['element:q']]], [{ref:{...ref('one'),asset:{...ref('one').asset,width:3}},bytes}])}),'shared_asset_identity_conflict');assert(await count()===0&&(await storage.recover(q)).rootRevision===1,'identity conflict partially committed bytes or Root');
|
||||
// Force a later files-store conflict after the depot puts: the whole transaction must roll back.
|
||||
// 先让 depot 排入写入,再由 files 的重复身份触发失败;检查整笔 IDB 事务回滚,而非只测发送前校验拒绝。
|
||||
await storage.commit(q,{image:image(2),files:[{id:'existing',bytes}],depot:cut()});
|
||||
await rejects(()=>storage.commit(q,{image:image(3),files:[{id:'existing',bytes}],depot:cut([['one',['element:q']]], [{ref:ref('one'),bytes}])}),'resource_identity_conflict');assert(await count()===0&&(await storage.recover(q)).rootRevision===2,'late failure committed depot or Root');
|
||||
await storage.commit(q,{image:image(3),depot:cut([['one',['element:q']]], [{ref:ref('one'),bytes}])});assert(await count()===1&&(await storage.assetDepot.read(q,authority,'one')).purgedAt===undefined,'authorized rehydration failed');
|
||||
// A one-item sweep must provide a cursor and preserve each resource decision.
|
||||
// limit=1 强制分两页;nextAfter 是资源身份游标,第二页结束才表示这一轮扫描完成。
|
||||
const first=await collect(q,130,{limit:1});assert(first.nextAfter==='one','bounded sweep cursor missing');assert((await collect(q,130,{after:first.nextAfter,limit:1})).nextAfter===undefined,'bounded sweep did not finish');
|
||||
// Exercise the actual engine persistence entry point, rather than only hand-built batches.
|
||||
// 从手工 batch 检查切换到真实引擎:stageFiles、确认上传及关闭后,再检查物理文件行。
|
||||
const projectId='engine-project',registry=createRegistry(builtinComponents());let document=createDocument(projectId,[{id:'canvas',parent:null}],[]),version=1,counter=0,resource,uploads=0;
|
||||
// 模拟上传回执及 authority;此场景不应触发已有资源接纳,上传返回原始字节的服务端身份。
|
||||
|
||||
Reference in New Issue
Block a user