mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
fix: Allow DataAccessorBasedStore to create root
This commit is contained in:
parent
209b87a424
commit
a08b7e9112
@ -218,7 +218,8 @@ export class DataAccessorBasedStore implements ResourceStore {
|
||||
await this.handleContainerData(representation);
|
||||
}
|
||||
|
||||
if (createContainers) {
|
||||
// Root container should not have a parent container
|
||||
if (createContainers && !this.identifierStrategy.isRootContainer(identifier)) {
|
||||
await this.createRecursiveContainers(this.identifierStrategy.getParentContainer(identifier));
|
||||
}
|
||||
|
||||
|
@ -343,6 +343,21 @@ describe('A DataAccessorBasedStore', (): void => {
|
||||
new ConflictHttpError(`Creating container ${root}a/ conflicts with an existing resource.`),
|
||||
);
|
||||
});
|
||||
|
||||
it('can write to root if it does not exist.', async(): Promise<void> => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
||||
delete accessor.data[root];
|
||||
const resourceID = { path: `${root}` };
|
||||
|
||||
// Generate based on URI
|
||||
representation.metadata.removeAll(RDF.type);
|
||||
representation.metadata.contentType = 'text/turtle';
|
||||
representation.data = guardedStreamFrom([]);
|
||||
await expect(store.setRepresentation(resourceID, representation)).resolves.toBeUndefined();
|
||||
expect(accessor.data[resourceID.path]).toBeTruthy();
|
||||
expect(Object.keys(accessor.data)).toHaveLength(1);
|
||||
expect(accessor.data[resourceID.path].metadata.contentType).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('modifying a Representation', (): void => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user