chore: Remove assumption that DataAccessors have a root container by default

This commit is contained in:
Joachim Van Herwegen
2020-12-14 15:49:58 +01:00
parent 231349b30d
commit 36eed5d620
12 changed files with 86 additions and 33 deletions

View File

@@ -18,6 +18,9 @@ describe('An InMemoryDataAccessor', (): void => {
beforeEach(async(): Promise<void> => {
accessor = new InMemoryDataAccessor(base);
// Create default root container
await accessor.writeContainer({ path: `${base}` }, new RepresentationMetadata());
metadata = new RepresentationMetadata({ [CONTENT_TYPE]: APPLICATION_OCTET_STREAM });
data = guardedStreamFrom([ 'data' ]);

View File

@@ -121,26 +121,6 @@ describe('A SparqlDataAccessor', (): void => {
]));
});
it('generates resource metadata for the root container.', async(): Promise<void> => {
metadata = await accessor.getMetadata({ path: base });
expect(metadata.quads()).toBeRdfIsomorphic([
quad(namedNode('this'), namedNode('a'), namedNode('triple')),
quad(namedNode(base), toNamedNode(RDF.type), toNamedNode(LDP.Container)),
quad(namedNode(base), toNamedNode(RDF.type), toNamedNode(LDP.BasicContainer)),
quad(namedNode(base), toNamedNode(RDF.type), toNamedNode(LDP.Resource)),
]);
expect(fetchTriples).toHaveBeenCalledTimes(1);
expect(fetchTriples.mock.calls[0][0]).toBe(endpoint);
expect(simplifyQuery(fetchTriples.mock.calls[0][1])).toBe(simplifyQuery([
'CONSTRUCT { ?s ?p ?o. } WHERE {',
` { GRAPH <${base}> { ?s ?p ?o. } }`,
' UNION',
` { GRAPH <meta:${base}> { ?s ?p ?o. } }`,
'}',
]));
});
it('throws 404 if no metadata was found.', async(): Promise<void> => {
// Clear triples array
triples = [];