P2-03: manage hashed OPFS project resources
This commit is contained in:
@@ -112,6 +112,21 @@ test('project persistence remains behind the facade contract', async () => {
|
||||
assert.equal(facade.project.capabilities().mode, 'sqlite-memory')
|
||||
})
|
||||
|
||||
test('project resources use content identity and reference counting', async () => {
|
||||
const facade = createMockFacade()
|
||||
const bytes = new Uint8Array([1, 2, 3, 5, 8])
|
||||
const first = await facade.project.resource.put(bytes, 'application/octet-stream')
|
||||
const second = await facade.project.resource.put(bytes, 'application/octet-stream')
|
||||
assert.equal(first.hash, second.hash)
|
||||
assert.equal(second.refCount, 2)
|
||||
bytes[0] = 99
|
||||
assert.deepEqual([...((await facade.project.resource.get(first.hash)) || [])], [1, 2, 3, 5, 8])
|
||||
await facade.project.resource.release(first.hash)
|
||||
assert.deepEqual([...((await facade.project.resource.get(first.hash)) || [])], [1, 2, 3, 5, 8])
|
||||
await facade.project.resource.release(first.hash)
|
||||
assert.equal(await facade.project.resource.get(first.hash), null)
|
||||
})
|
||||
|
||||
test('Part Design feature tasks commit a document object and remain undoable', () => {
|
||||
const facade = createMockFacade()
|
||||
const before = facade.app.document.getActive()
|
||||
|
||||
Reference in New Issue
Block a user