Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/resource/resourceLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ export function createResourceLogic(store, aclLogic: AclLogic, containerLogic, t
}

if (resourceParent) {
store.removeMatches(resourceParent, ns.ldp('contains'), resourceNode, resourceParent.doc())
store.removeMatches(resourceParent, ns.ldp('contains'), resourceNode)
}

store.removeDocument(resourceNode)
Expand Down
19 changes: 17 additions & 2 deletions test/resourceLogic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ describe('resourceLogic', () => {
expect(store.fetcher._fetch).toHaveBeenCalledWith(member.value, { method: 'DELETE' })
expect(store.fetcher._fetch).toHaveBeenCalledWith(container.value, { method: 'DELETE' })
expect(store.removeMatches).toHaveBeenCalledTimes(2)
expect(store.removeMatches).toHaveBeenNthCalledWith(1, container, sym('http://www.w3.org/ns/ldp#contains'), member, container.doc())
expect(store.removeMatches).toHaveBeenNthCalledWith(2, sym('https://example.com/'), sym('http://www.w3.org/ns/ldp#contains'), container, sym('https://example.com/').doc())
expect(store.removeMatches).toHaveBeenNthCalledWith(1, container, sym('http://www.w3.org/ns/ldp#contains'), member)
expect(store.removeMatches).toHaveBeenNthCalledWith(2, sym('https://example.com/'), sym('http://www.w3.org/ns/ldp#contains'), container)
expect(store.removeDocument).toHaveBeenCalledWith(member)
expect(store.removeDocument).toHaveBeenCalledWith(container)
})
Expand Down Expand Up @@ -125,6 +125,21 @@ describe('resourceLogic', () => {
expect(store.removeDocument).toHaveBeenCalledWith(resource)
})

it('surfaces document cleanup failures instead of reporting success', async () => {
const resourceLogic = createResourceLogic(store, aclLogic, containerLogic, typeIndexLogic)
const resource = sym('https://example.com/resource.ttl')

containerLogic.isContainer.mockReturnValue(false)
store.removeDocument.mockImplementation(() => {
throw new Error(
'Statement to be removed is not on store: <https://example.com/resource.ttl> <http://www.w3.org/2007/ont/link#uri> "https://example.com/resource.ttl"'
)
})

await expect(resourceLogic.recursiveDelete(resource)).rejects.toThrow('Statement to be removed is not on store:')
expect(store.fetcher.unload).not.toHaveBeenCalled()
})

it('recognizes only profile-card.ttl WebIDs', () => {
const resourceLogic = createResourceLogic(store, aclLogic, containerLogic, typeIndexLogic)

Expand Down
Loading